playingField -values: Arra Field wheels: Array List +Wheel() +spin(): St +Playin
ID: 3823220 • Letter: P
Question
playingField -values: Arra Field wheels: Array List +Wheel() +spin(): St +Playing Field0 SlotMachine: Add a set Bonus method which creates an instance of Bonus Playing Field and saves it in its playingField attribute. Add a set Regular method which creates an instance of Playing Field and saves it in its playingField attribute. Change the line in the SlotMachine constructor that ed createst the Playing Field object to just call the setRegular method. Bonus PlayingField added or revise this lab assignm onus inglieloExplanation / Answer
So there are two classes
1) Slot Machine
2) Launcher
Now lets first try to understand what Slot machine is doing.
There are two functions and setBonus() and setRegular(). setBonus() create a new instance of BonusPlayingFiled whereas set Regular() create the instance of PlayingFeild object.
Now coming to Launcher class, we have:
a static counter, which will increment the counter on each spin. If it reahces the five, then we have to create BonusPlayingField object,which means we should call setBonus(). If the counter stops, we have call setRegular().
So, i will provide a skeleton code to make it understand better.
class SlotMachine{
public void setBonus(){
new BonusPlayingField();
}
public void setRegular(){
new PlayingField();
}
SlotMachine()
{
setRegular();
]
}
public class Launcher{
static counter =0 ;
//increment on each spin
counter++;
SlotMachine sm = new SlotMachine();
if(counter==5)
{
sm.setBonus();
}
if(counter==stops)
{
sm.setRegular();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.