• Sat. Oct 1st, 2022

    Programming in Java to implement the following dice games: drop the two dice, if the total value of the score is 7 points, "win"; otherwise "loses".

    ByGoodBoy

    Sep 23, 2022
    2 thoughts on “Programming in Java to implement the following dice games: drop the two dice, if the total value of the score is 7 points, "win"; otherwise "loses".”
    1. Public class test {
      Public static void main (string [] art) {
      diegame diegame = new diegame ();
      if (diegame.play ()) {
      system. out.println ("You won!");
      } else {
      system.out.println ("You lose!");
      } n}
      }

      CLASS DIE {
      private int facevalue;

      public int () {
      return facevalue; void (int Facevalue) {
      this.Facevalue = facevalue;
      }
      n public void roll () {
      this.FaceValue = (math.randomomompo () * 6 1);

      }
      }

      Class diegame {
      private deps die1 = new die ();
      private Die Die2 = New Die ();

      Public Boolean Play () {
      die1.roll ();
      system.out.println ("first point: die1. ());
      die2.roll ();
      system.out.println ("second point:" die2. ());
      if (die1. () die2. () == 7) {
      return true;
      } else {
      return false;
      }
      } n}

    2. Private dicegame game;
      // Add the get, set method
      public static void main (string [] args) {
      if (game.play ()) {
      system.out .print ("Victory");
      } else {
      system.out.print ("Failure");
      }
      }

    Leave a Reply