Question: Can someone please give me the code for part B tasks 1 and 2 please. The code for part A was : public class Main

Can someone please give me the code for part B tasks 1 and 2 please. The code for part A was :

public class Main

{

public static void main(String[] args)

{

World world = new World();

world.run();

}

}

-------------------------------------------------------------------------------------------------------

public class Player

{

private static int count;

private String name;

private int unplacedArmies;

public Player()

{

count++;

System.out.print("Enter player " + count + "'s name: ");

this.name = World.keyboard.nextLine();

unplacedArmies = 3;

}

public String toString()

{

return name;

}

public void placeArmies(int armies, Territory territory)

{

unplacedArmies -= armies;

territory.placeArmies(this, armies);

}

}

---------------------------------------------------------------------------------------------------

public class Territory

{

private int row;

private int column;

private Player owner;

private int armies;

public Territory(int column, int row)

{

this.column = column;

this.row = row;

}

public String toString()

{

return "[" + column + "," + row + "]" + owner + "(" + armies + ")";

}

public void placeArmies(Player owner, int armies)

{

this.owner = owner;

this.armies += armies;

}

}

-----------------------------------------------------------------------------------------------

import java.util.Scanner;

public class World

{

public static final Scanner keyboard = new Scanner(System.in);

private Territory territory1;

private Territory territory2;

private Territory territory3;

private Territory territory4;

private Player player1;

private Player player2;

public World()

{

territory1 = new Territory(0, 0);

territory2 = new Territory(1, 0);

territory3 = new Territory(0, 1);

territory4 = new Territory(1, 1);

player1 = new Player();

player2 = new Player();

}

public String toString()

{

return territory1 + " " + territory2 + " " + territory3 + " " + territory4;

}

public void placeArmies(Player player, Territory territory)

{

System.out.print("How many armies would you like to place on " + territory + "? ");

int armies = keyboard.nextInt();

player.placeArmies(armies, territory);

System.out.println(this);

}

public void run()

{

System.out.println(player1 + ", please place your armies");

System.out.println(this);

placeArmies(player1, territory1);

placeArmies(player1, territory2);

System.out.println(player2 + ", please place your armies");

System.out.println(this);

placeArmies(player2, territory3);

placeArmies(player2, territory4);

}

}

Can someone please give me the code for part B tasks 1and 2 please. The code for part A was : public classMain { public static void main(String[] args) { World world = newWorld(); world.run(); } } ------------------------------------------------------------------------------------------------------- public class Player { private static int

310 Part B 31 Due date: 11:59pm on Sunday October 21, 2018 (i.e. 21/10/2018, 11:59pm) 312 Value: 21% 313 Topics: Data flow, OO programming basics, Control flow 314 Objectives: This assignment supports objectives 1-5 315 Introduction 316 317 In Part B you will finish the game that you started building in Part A. You will use your solution to Part A as your starting point. 318 Note!! Your Part B solution should be submitted on PLATE under the link "Domination 319 Assignment Part B 2018 Spring". Be careful not to submit under the link for "Part A". 320In your completed game, each player will have alternating turns until one player has dominated 321 the world (i.e. is the owner of all territories). The first turn of each player involves only one 322 step: 323 324 325 326 327 . Place armies However, any turn after the first turn will have more steps 6. 7. 8. Place armies Attack territories owned by other players Transfer armies between the plaver's own territories 328After completing a turn, if the winner has not yet been decided, control transfers to the next 329 player. 330 Tasks 331 332 333 334 Some of the following tasks are divided into a "basic feature" which is necessary to complete before continuing to the next task, and an "advanced feature" which will give you extra marks but is not necessary to complete before continuing to the next task. It is possible to skip an advanced feature and come back to it later 335 Task 1: place armies 336 Basic feature 310 Part B 31 Due date: 11:59pm on Sunday October 21, 2018 (i.e. 21/10/2018, 11:59pm) 312 Value: 21% 313 Topics: Data flow, OO programming basics, Control flow 314 Objectives: This assignment supports objectives 1-5 315 Introduction 316 317 In Part B you will finish the game that you started building in Part A. You will use your solution to Part A as your starting point. 318 Note!! Your Part B solution should be submitted on PLATE under the link "Domination 319 Assignment Part B 2018 Spring". Be careful not to submit under the link for "Part A". 320In your completed game, each player will have alternating turns until one player has dominated 321 the world (i.e. is the owner of all territories). The first turn of each player involves only one 322 step: 323 324 325 326 327 . Place armies However, any turn after the first turn will have more steps 6. 7. 8. Place armies Attack territories owned by other players Transfer armies between the plaver's own territories 328After completing a turn, if the winner has not yet been decided, control transfers to the next 329 player. 330 Tasks 331 332 333 334 Some of the following tasks are divided into a "basic feature" which is necessary to complete before continuing to the next task, and an "advanced feature" which will give you extra marks but is not necessary to complete before continuing to the next task. It is possible to skip an advanced feature and come back to it later 335 Task 1: place armies 336 Basic feature

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!