# CST338 Week 2 – Casino Slot Machine Simulator

Hello this video would be about how I
think this assignment can be solved The assignment this week is to create a
casino slot machine on Java and I’ll call it a casino slot machine simulator the key concepts that are needed in order to create the slot machine simulator is
first being able to understand how strings work it is important to know that each element of the slot will be a randomized string, the second concept
needed is knowing how to generate random numbers so that it in select random slot
strings with a select probability another important concept is knowing how
to assign the strings into an array this is necessary since the slots order
matters for the winning patterns and finally basic math is needed to
calculate the winnings of the player before we start coding the program we
should first plan on how the program should function and in what order.
the program should provide the user with an initial balance so that they can start
betting then we should have the player bet however much they want to start the slots.
then we roll the slots by randomly selecting strings based on a set probability,
once the slots has been selected the slots should be displayed for the player to see
the slots then should be checked at the player has won or not and
then the players balance must be updated based on the winnings which is
multiplied from their initial bet or their loss then the player can continue
playing or quit the slot machine simulator next we will be going through
each of the required classes for this program to work the first class would be
to get bet which is the only part of the program that will receive the user’s input
the purpose of get bet class is to get the players input preferably an
integer to use as the amount that they bet on the slots
however there should be a follow-up method that will quit the program if the user enters 0
to be able for the player to input their bet amount the Java program should have
an import with java.util.scanner but the data enter can be long or int but since
the class returns an int it should be converted to an integer value
the triple string pull class is one of the random slots are returned after it has been generated
it returns a triple string object which should have an
array of the 3 slot strings in order
it would use the random string class which would be
explained later on to generate these random slots the class rand string needs to generate the random string for each slot this class should have the
probability for each of the strings an if statement can be used after a number is
randomly generated possibly from 1 to 100 with the math.random function in
order to select a string this is done by multiplying the randomly generated
number by 100 then the randomized string is returned the displayed class does not
return a value when it is being called this class takes the object of triple
string which has named the pull which should contain the results of the
randomized slots most likely in an array it also takes the calculated
winnings based on the order of the strings in the array the console then
display the results of the slots and the winnings if the player has won or lost
there are a few ways to save the amount that the player has won the first method
would be to have the triple string class calculate the winnings and save the
winnings into a variable the second method is to create an array in the main
class so that the winnings can be appended to array and when the program
ends the array can be used to display the winnings of each round and the total
amount that the player has won or lost for the main class this will be where
all the other classes can be used in order to create the slot machine
simulation the get bet class is the only class that accepts the user input
so it should be used here the main class should have a loop where it first
uses to get bet function to first determine how much the player bets and
if it is a zero it will exit the loop otherwise it will continue with the loop
where it would generate the random strings for the slots and then display
that the player has won or lost the players balance is then updated and the
loop repeats to ask if a player wants to bet again here are some tips that you
may want to consider as you tackle this assignment before writing the main class
try to test each of the other classes to make sure that there are no mistakes so
that the program can run smoothly also check out the main classes through loops
and ends properly finally try legal inputs to see if the program can handle
such a situation that is my video on how I would solve this assignment
thanks for watching