SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 313 Weeks Ago, 6 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 30 Nov 2017 My Price 8.00

Implement a version of the Die class that automatically

My professor has provided this below:

We are instructed the following:

 

4.     Implement a version of the Die class that automatically rolls the die when created

a.   Class name is DieVer2

b. The constructor is: public DieVer2()

c. The public methods are public void roll() and public int getNumber()

 

5.     Implement a many-sided die class that takes the number of sides as a constructor parameter and whether to roll in the constructor.

a.   Class name is ManySidedDi e

b. The constructor is: public ManySidedDie(int sides, boolean roll)

c. The public methods are public void roll() and public int getNumber()

 

 

package week04;

import java.util.Random;

/**

 * This class simulates a dice

 * It utilizes the Random class to generate a random number

 *

 * @author Ashlee

 *

 */

public class Die

{

   // Constructor

   public Die()

   {

       random = new Random();

       number = NO_NUMBER;

   }

   // Rolls the dice

   public void roll()

   {

       number = random.nextInt(MAX_NUMBER - MIN_NUMBER + 1) + MIN_NUMBER;

   }

   // Returns the number on this dice

   public int getNumber()

   {

       return number;

   }

   // Data Members

   // the largest number on a dice

   private static final int MAX_NUMBER = 6;

   // the smallest number on a dice

   private static final int MIN_NUMBER = 1;

   // to represent a dice that is not yet rolled

   private static final int NO_NUMBER = 0;

   private int number;

   private Random random;

}

Answers

(5)
Status NEW Posted 30 Nov 2017 08:11 AM My Price 8.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)