The 'main' class is LotsOfDiceRoller.java. The code is reasonably written but not very 'object oriented'. There is also

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

The 'main' class is LotsOfDiceRoller.java. The code is reasonably written but not very 'object oriented'. There is also

Post by answerhappygod »

The 'main' class is LotsOfDiceRoller.java. The code is
reasonably written but not very 'object oriented'. There is also a
class called Die. This class is complete and needs no additional
work.
You will write a class that will be a container for a number of
Die. I have given a skeleton of code for the new class,
DieCollection. There are instructions in the file
LotsOfDiceRoller.java in comments starting with 'TODO'. Follow the
comments and make the changes suggested. The new code should use
only DieCollection (and DieCollection should hold an array with a
collection of Die objects.) This will make the code much more
object-oriented.
Die.java
Diecollection.java
LotsOfDiceRoller.java
Start by running the existing code. The code should work. It
provides a menu allowing you to change the number of faces on a
die, change the number of dice, and roll the dice. Play with the
program and see how it responds. After that, begin making the
changes. Modify the code given for DieCollection adding in the code
I describe. You may want to create a 'UseDieCollection' class to
test the various methods as you write them (it is your choice.)
When DieCollection is complete, start making the modifications
in LotsOfDiceRoller.java to create a DieCollection object and use
that for all the functions in the program rather than a local array
and local variables in main.
Make sure that your program works
correctly.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply