Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

did not do well on quiz, can someone walk me through it so I can understand it :( CSC 1302 -39, 42,45,28, Spring 2019, Quiz

did not do well on quiz, can someone walk me through it so I can understand it :(

image text in transcribedimage text in transcribed

CSC 1302 -39, 42,45,28, Spring 2019, Quiz 1 Name: Lab Day and time:DAY public class dice( String name: int sides Given the dice class above, point out the errors in the following constructor and show how to fix them. (15 points) (5 points for each error) 1. public (void)dice (String NAME, int FACES) ame NAME -2.S ( int sides FACES; P volic ciass ice (Str Given the dice class above, write the output after the following code executes? (T0 points) (5 points for correct each output) 2. dice dl new dice) dice d2 new dice) d1.name-"Dhara's dice" d1.sides 13: d2.name = "Normal dice"; d2.sides-di.faces 7; System.out.println (d1.name " has "+dl.sides) System.out.printin (d2.name +" has "+dz.sides)i Dh ara 's dice has 13 Normai eice has 6 Change the above calls to make the fields private. After you make them private you will not be able to access or change the values of these fields directly. Add the accessors and mutators to the following class so that you can access and change the values of these fields. (50 points) 3. public class dicel // private fields (5 points for each correct modification) e rivate class dice SO // accessors to the fields (10 points for each) e name // mutators of the fields (10 points for each) 4. For the above dice class, suppose Random is imported. In your class methods, you can instantiate random with Random r- new Random0: Write a dice class method to roll it. (20 points) (Be careful! What range do you want the die to roll to? What do you think it should return? Would it take any parameters?)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions