Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Develop the game using the concepts of Cohesion, Coupling and RDD, i.e., respons

ID: 3551214 • Letter: D

Question

  1. Develop the game using the concepts of Cohesion, Coupling and RDD, i.e., responsibility-driven design.
    1. Note that each class should represent one logical entity
    2. Also note that each method should perform one logical task
    3. Aim for high cohesion and low coupling
    4. Atleast 3 classes.
create a game using simple java programming that allows a human player to play against the computer, or have the computer play against itself. The game is Odds or Evens where the human player enters a 1 or a 2 as their create a game using simple java programming that allows a human player to play against the computer, or have the computer play against itself. The game is Odds or Evens where the human player enters a 1 or a 2 as their

Explanation / Answer

public class Player{ public boolean isHuman; public int score =0; private Scanner input; public Player(int human){ if(human > 0) isHuman=true; else isHuman=false; } public void play(){ if(isHuman) playHuman(); else playComp(); } public void playHuman(){ input =new Scanner(System.in); int current = 0; //int payment =0; int again =1; while (again==1){ System.out.println("Enter a 1 or 2 for your throw"); current = input.nextInt(); int value = (int) Math.random() * 3; score = (current + value); if(score % 2==0) System.out.println("You Win!"); else System.out.println("Sorry, you lose."); } } public void playComp(){ int current =0; int payment =0; int value = (int) Math.random() * 5; score = (current + value); } }




public class Player{ public boolean isHuman; public int score =0; private Scanner input; public Player(int human){ if(human > 0) isHuman=true; else isHuman=false; } public void play(){ if(isHuman) playHuman(); else playComp(); } public void playHuman(){ input =new Scanner(System.in); int current = 0; //int payment =0; int again =1; while (again==1){ System.out.println("Enter a 1 or 2 for your throw"); current = input.nextInt(); int value = (int) Math.random() * 3; score = (current + value); if(score % 2==0) System.out.println("You Win!"); else System.out.println("Sorry, you lose."); } } public void playComp(){ int current =0; int payment =0; int value = (int) Math.random() * 5; score = (current + value); } }