1 Replies - 856 Views - Last Post: 23 March 2013 - 04:36 PM

#1 Robfella  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 23-March 13

Problem with slot machine sim OOprogramming!

Posted 23 March 2013 - 04:19 PM

I'm making this slot machine sim and it asks about what a slot machine has. Here's the spec. I'm not asking for code, just direction.

Specific requirements: You must solve this using an object-oriented approach. Create a class called SlotMachine.
Think about:
What does a SlotMachine Have?
What does it do?
What information does it maintain?
This is the “state” and “behavior” of the object. Each instance of this class will represent a single slot machine.

---


Right now all I can think of is a playCount variable and a name, is that enough?

Also, I'm confused because each slot machine. They all have different parameters:

She plays three machines in turn. Unknown to her, the machines are entirely predictable. Each play costs one quarter. The first machine pays 30 quarters every 35th time it is played; the second machine pays 60 quarters every 100th time it is played; the third pays 11 quarters every 10th time it is played. (If she played the 3rd machine only she would be a winner.)
----
If I'm using the same SlotMachine object to create a game with three different Slot Machines(all having different payouts), shouldn't I use 3 different slot machine objects? or could I use a switch?

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with slot machine sim OOprogramming!

#2 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3809
  • View blog
  • Posts: 13,519
  • Joined: 12-December 12

Re: Problem with slot machine sim OOprogramming!

Posted 23 March 2013 - 04:36 PM

You said it yourself:

Quote

Also, I'm confused because each slot machine. They all have different parameters:

Your assignment is to create "a class called SlotMachine". You could create a constructor for the class that accepts parameters, such as the payout information, and/or create methods of your class that allow these parameters (its state) to be changed.

So, yes, you would use the class to create three instances of the class, but each instance (each object) would be slightly different.

This post has been edited by andrewsw: 23 March 2013 - 04:37 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1