Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

swift programing The first tab will allow the user to play a 3-Digit Slot Machine. The second tab will allow the user to play a

swift programing

The first tab will allow the user to play a 3-Digit Slot Machine.

The second tab will allow the user to play a 5-Digit Slot Machine.

Required Tasks (100 points)

Each tab should have:

The appropriate number of digits.

A Spin button.

A Reset button.

A Score label.

You will need to have a Digit class that represents each digit. The properties of each digit are:

Each digit can be in the range 0-9.

Each digit can have one of the following colors:

Red

Blue

Green

Purple

Your Digit class must have the following functions:

spinDigit() - This method randomly selects a digit from 0-9 and sets it's color.

pickDigit() -> UInt32 - This method randomly selects a digit and returns it.

pickColor() -> UIColor2 - This method randomly selects a color and returns it.

getDigit() -> UInt32 - This method returns the current digit.

getColor() -> UIColor - This method returns the current color.

You will need to have a SlotMachineGame class that manages the spinning and the score. The SlotMachineGame should:

Manage the changing of the digits.

Manage the score as follows:

A new game starts with a score of 100.

Each spin costs the player two points.

All digits equal and colors equal (Ex. 5 5 5 or 2 2 2 2 2 ) the user earns 300 points in the 3-Digit game and 500 points in the 5-Digit game.

All colors equal but digits differ (Ex. 3 5 7 or 1 4 9 3 5 ) the user earns 75 points in the 3-Digit game and 125 points in the 5-Digit game.

All digits equal but colors differ ( 7 7 7 or 1 1 1 1 1 ) the user earns 150 points in the 3-Digit game and 250 points in the 5-Digit game.

When the user has a score less than 2, the Spin button should be disabled.

Your SlotMachine class must have the following functions:

init(_ numberOfDigits : Int) - Initializes a new game with the specified number of digits.

resetGame() - Resets to game to beginning with a score of 100.

getScore() -> Int - Returns the current score.

getDigits() -> [Digit] - Returns the game's array of Digits.

spinDigits() - This method spins all the Digits that are part of this game.

Pressing the Spin button should cause all the digits to change to random digits and random colors.

Pressing the Reset button should cause the game to reset the score to 100.

You should use Auto Layout so your game can be used in both Portrait as well as Landscape mode.

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_2

Step: 3

blur-text-image_3

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

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

=+1. What are the forces compelling your organization to change?

Answered: 1 week ago