During each round, players choose a move, which may be either Gödishus, Derflürg, Kullen, Koppang, or Songesand. The rules are:

  • Songesand beats Kullen, Gödishus
  • Kullen beats Derflürg, Koppang
  • Derflürg beats Songesand, Gödishus
  • Gödishus beats Koppang, Kullen
  • Koppang beats Songesand, Derflürg

Your program should behave as follows:

  • The rules should be printed to the screen
  • The user is asked if they’d like to play a round
    • if they choose ‘y’, a round is played
    • if they choose ‘n’, the program ends
  • Until the user has chosen to quit, another round is played.
  • In a round of play:
    • The user is asked to enter a move, which may be either Gödishus, Derflürg, Kullen, Koppang, or Songesand. The program should continue to prompt the user until a valid move is entered.
    • The computer makes a move at random. (Hint: remember how we generated random numbers in class.)
    • The program prints the computer’s move, the user’s move, and who is the winner of this round.
    • The user is asked if they’d like to continue.
  • When the user has decided to quit the game, the program prints the number of:
    • rounds played
    • times the user won
    • times the computer won

    using switch and here is some suggestion:

    /* use named constants */_x000D_
    public static final int GODISHUS = 0;_x000D_
    public static final int DERFLURG = 1;_x000D_
    public static final int KULLEN = 2;_x000D_
    public static final int KOPPANG = 3;_x000D_
    public static final int SONGESAND = 4;_x000D_
    /* write a method that is passed two moves and returns who wins */_x000D_
    public static boolean userWon(int userMove, int computerMove) {_x000D_
      /* good */_x000D_
      if (userMove == GODISHUS && (computerMove == DERFLURG ||_x000D_
                                   computerMove == WHATEVER))_x000D_
    _x000D_
      /* not as good */_x000D_
      if (userMove == 1 && computerMove == 2 || computerMove .._x000D_
            _x000D_
    }_x000D_
    _x000D_
    /* returns computer's random move */_x000D_
    public static int randMove() {_x000D_
    ..._x000D_
    }_x000D_
    _x000D_
    ..._x000D_
    _x000D_
    /* using the method */_x000D_
    int computerMove = randMove();_x000D_
    System.out.println("computer entered: " +_x000D_
                        intMoveToString(computerMove));_x000D_
    /* in response to question about what would happen_x000D_
       if we really wanted the String representation of _x000D_
       a move */_x000D_
    public static String intMoveToString(int m) {_x000D_
      if (m == GODISHUS) {_x000D_
         return "Godishus";_x000D_
      } else if (m == DERFLURG) {_x000D_
         ..._x000D_
      }_x000D_
    _x000D_
      etc._x000D_
    }

 

Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code “Newclient” for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.


The post java programming 88 appeared first on Custom Nursing Help.

 

"Is this question part of your assignment? We Can Help!"

Essay Writing Service