|
-
January 21st, 2011, 01:25 PM
#1
I am Almost Done!
Okay so I finished my Slot Machine Code! Well Almost! It works it is good and ya if you have any comments saying why didnt you put the numbers into arrays, well ya I never really understood that while I was making the actual game! O well! Atleast it works!
Now all I am asking you guys is do you guys have any simple methods I can put into this program just to make it a bit better? A couple of methods are fine! And if you could also give me an example of the method! Other thaan that thanks so much for your hellp on this forum!
Code:
// import the java.util.Random class:
import java.io.*;
import java.util.Random;
public class SlotMachine
{
public static void main(String args[]) throws IOException{
Random randomizer = new Random();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
String b; int bi=0;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader reader= new BufferedReader(input);
// Make the player think that they have a high chance of winning, even if they don't!
System.out.println("Welcome to *Saim's* Casino");
System.out.println("Unfortunately we only have one machine available at this moment");
System.out.println("Just because of the lack of variety in games, odds of winning this game are really good");
System.out.println("The game is called Saim's Slots");
System.out.println("All you do is enter in $100 by simply typing in 100 when prompted");
System.out.println("That will allow you to spin once!");
System.out.println("Now you might be saying ***! It is so expensive");
System.out.println("Well there are 53 different ways towin in this casino!");
System.out.println("Basically you hav to do is make 2 pairs in a row!");
System.out.println("For example : 2,2 & 3,3");
System.out.println("If you get that you win money upto $10000");
System.out.println("The prize money increases if you match another 2 pairs in a row");
System.out.println("For example: Horizontally: 2,2 & 3,3 & Vertically 4,4 & 5,5");
System.out.println("It can be in any order but you will definetly win the prize!");
System.out.println("If you get all the numbers to match you win the Jackpot!");
System.out.println("All this just for a $100");
System.out.println("Unless you are feeling unlucky today, go ahead and make your self richer!");
System.out.println("So what are you waiting for? Luck is on your side!");
// Enter in the money
System.out.println("Please enter in the $100 by typing in 100");
b=reader.readLine();
bi=Integer.parseInt(b);
while (bi==100) {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Initialize variables in the actualy machine so they generate a random number between 0 and 7
int ci = randomizer.nextInt(7);
int di = randomizer.nextInt(7);
int ei = randomizer.nextInt(7);
int fi = randomizer.nextInt(7);
int gi = randomizer.nextInt(7);
int hi = randomizer.nextInt(7);
int ii = randomizer.nextInt(7);
int ji = randomizer.nextInt(7);
int ki = randomizer.nextInt(7);
int li = randomizer.nextInt(7);
int mi = randomizer.nextInt(7);
int ni = randomizer.nextInt(7);
int oi = randomizer.nextInt(7);
int pi = randomizer.nextInt(7);
int qi = randomizer.nextInt(7);
int ri = randomizer.nextInt(7);
// Print out the actual slot machine numbers through the initialize variables!
System.out.println(ci +"\t" + di+"\t" + ei+"\t" + fi);
System.out.println(gi +"\t" + hi+"\t" + ii+"\t" + ji);
System.out.println(ki +"\t" + li+"\t" + mi+"\t" + ni);
System.out.println(oi +"\t" + pi+"\t" + qi+"\t" + ri);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Put the money into arrays so it outputs upto $10000
Random money = new Random();
int[] x = new int[4];
for (int m=0; m<x.length; m++)
{
x[m] = (money.nextInt(10000));
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// If every number matches you win the Jackpot giving them the highest chance to win more money!
if (((((ci==di)&&(di==ei))&&(ei==fi))&&(fi==ji))&&(ii==hi)&&(hi==gi)&&(gi==ki)&&(ki==li)&&(li==mi)&&(mi==ni)&&(oi==pi)&&(qi==ri)){
System.out.println(" OMFG You won $" + x[0] + x[1] + x[2] + x[3] + x[4]);}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// If that dosen't work check if numbers match in the 1st row, diagonally starting from the 1st number on the 4th row, and the 3rd row!
else if (((((ci==di)&&(ei==fi))&&(fi==ii))&&(li==oi))&&(ki==li)&&(mi==ni)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 2nd row, 3rd row and the 4th row!
else if (((((gi==hi)&&(ii==ji))&&(ki==li))&&(mi==ni))&&(oi==pi)&&(qi==ri)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st row, 2nd row and the 3rd row!
else if (((((ci==di)&&(ei==fi))&&(gi==hi))&&(ii==ji))&&(oi==pi)&&(qi==ri)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 2nd row, 3rd row and the 4th row!
else if (((((ci==di)&&(ei==fi))&&(ki==li))&&(mi==ni))&&(oi==pi)&&(qi==ri)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st column, 2nd column and the 3rd column!
else if (((((ci==gi)&&(ki==oi))&&(di==hi))&&(li==pi))&&(ei==ii)&&(mi==qi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 2nd column, 3rd column and the 4th column!
else if (((((di==hi)&&(li==pi))&&(ei==ii))&&(mi==qi))&&(fi==ji)&&(ni==ri)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 2nd row, 3rd row and the 4th row!
else if (((((ci==gi)&&(ki==oi))&&(di==hi))&&(li==pi))&&(fi==ii)&&(ni==ri)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st column, 3rd column and the 4th column!
else if (((((ci==gi)&&(ki==oi))&&(ei==ii))&&(mi==qi))&&(fi==ji)&&(ni==ri)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st row, 2nd row and diagonally starting from the first number!
else if (((((ci==di)&&(ei==fi))&&(gi==hi))&&(ii==ji))&&(ci==hi)&&(mi==ri)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st row, 2nd row and diagonally starting from the last number on the first row!
else if (((((ci==di)&&(ei==fi))&&(gi==hi))&&(ii==ji))&&(fi==ii)&&(li==oi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st row, diagonally starting from the 1st number and diagonally starting from the last number on the first row!!
else if (((((ci==di)&&(ei==fi))&&(ci==hi))&&(mi==ri))&&(fi==ii)&&(li==oi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 2nd row, 3rd row and diagonally starting from the first number!
else if (((((gi==hi)&&(ii==ji))&&(ki==li))&&(mi==ni))&&(ci==hi)&&(mi==ri)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 2nd row, 3rd row and the 1st column!
else if (((((gi==hi)&&(ii==ji))&&(ki==li))&&(mi==ni))&&(ci==gi)&&(ki==oi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 3rd row, 4th row and diagonally starting from the last number on the 1st row!!
else if (((((ki==li)&&(mi==ni))&&(oi==pi))&&(qi==ri))&&(fi==ii)&&(li==oi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st row, 2nd row and the 1st column!
else if (((((ci==di)&&(ei==fi))&&(gi==hi))&&(ii==ji))&&(ci==gi)&&(ki==oi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st row, 2nd row and the 2nd column!
else if (((((ci==di)&&(ei==fi))&&(gi==hi))&&(ii==ji))&&(di==hi)&&(li==pi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st row, 2nd row and the 3rd column!
else if (((((ci==di)&&(ei==fi))&&(gi==hi))&&(ii==ji))&&(ei==ii)&&(mi==qi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st row, 2nd row and the 4th column!
else if (((((ci==di)&&(ei==fi))&&(gi==hi))&&(ii==ji))&&(fi==ji)&&(ni==ri)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 2nd row, 3rd row and the 1st column!
else if (((((gi==hi)&&(ii==ji))&&(ki==li))&&(mi==ni))&&(ci==gi)&&(ki==oi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 2nd row, 3rd row and the 2nd column!
else if (((((gi==hi)&&(ii==ji))&&(ki==li))&&(mi==ni))&&(di==hi)&&(li==pi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 2nd row, 3rd row and the 3rd column!
else if (((((gi==hi)&&(ii==ji))&&(ki==li))&&(mi==ni))&&(ei==ii)&&(mi==qi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 2nd row, 3rd row and the 4th column!
else if (((((gi==hi)&&(ii==ji))&&(ki==li))&&(mi==ni))&&(fi==ji)&&(ni==ri)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st row, 3rd row and the 1st column!
else if (((((ci==di)&&(ei==fi))&&(ki==li))&&(mi==ni))&&(ci==gi)&&(ki==oi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st row, 3rd row and the 2nd column!
else if (((((ci==di)&&(ei==fi))&&(ki==li))&&(mi==ni))&&(di==hi)&&(li==pi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st row, 3rd row and the 3rd column!
else if (((((ci==di)&&(ei==fi))&&(ki==li))&&(mi==ni))&&(ei==ii)&&(mi==qi)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
// If that dosen't work check if numbers match in the 1st row, 3rd row and the 4th column!
else if (((((ci==di)&&(ei==fi))&&(ki==li))&&(mi==ni))&&(fi==ji)&&(ni==ri)){
System.out.println("You won $" + x[0] + x[1] + x[2]);}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// If that dosen't work check if numbers match in the 1st column and diagonally starting from the last number on the first row!
else if (((((fi==ji)&&(ni==ri))&&(fi==ii))&&(li==oi))){
System.out.println("You won $" + x[0] + x[1]);}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// If that dosen't work check if numbers match in the 3rd column and the 4th column!
else if (((((ei==ii)&&(mi==qi))&&(fi==ji))&&(ni==ri))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match in the 3rd column and diagonally starting from the last number on the 1st row!
else if (((((ei==ii)&&(mi==qi))&&(fi==ii))&&(li==oi))){
System.out.println("You won $" + x[0] + x[1]);}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// If that dosen't work check if numbers match diagonally starting from the first number and the 2nd column!
else if (((((ci==hi)&&(mi==ri))&&(di==hi))&&(li==pi))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match diagonally starting from the first number and the 3rd column!
else if (((((ci==hi)&&(mi==ri))&&(ei==ii))&&(mi==qi))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match diagonally starting from the first number and the 4th column!
else if (((((ci==hi)&&(mi==ri))&&(fi==ji))&&(ni==ri))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match diagonally starting from the first number and diagonally starting from the last number on the 1st row!
else if (((((ci==hi)&&(mi==ri))&&(fi==ii))&&(li==oi))){
System.out.println("You won $" + x[0] + x[1]);}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// If that dosen't work check if numbers match in the 1st column and diagonally starting from the 1st number!
else if (((((ci==gi)&&(ki==oi))&&(ci==hi))&&(mi==ri))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match in the 1st column and the 2nd column!
else if (((((ci==gi)&&(ki==oi))&&(di==hi))&&(li==pi))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match in the 1st column and the 3rd column!
else if (((((ci==gi)&&(ki==oi))&&(ei==ii))&&(mi==qi))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match in the 1st column and the 4th column!
else if (((((ci==gi)&&(ki==oi))&&(fi==ji))&&(ni==ri))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match in the 1st column and diagonally starting from the last number in the 1st row!
else if (((((ci==gi)&&(ki==oi))&&(fi==ii))&&(li==oi))){
System.out.println("You won $" + x[0] + x[1]);}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// If that dosen't work check if numbers match in the 1st row and the 1st column!
else if (((((ci==di)&&(ei==fi))&&(ci==gi))&&(ki==oi))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match in the 1st row and diagonally starting from the 1st number!
else if (((((ci==di)&&(ei==fi))&&(ci==hi))&&(mi==ri))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match in the 1st row and the 2nd column!
else if (((((ci==di)&&(ei==fi))&&(di==hi))&&(li==pi))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match in the 1st row and the 3rd column!
else if (((((ci==di)&&(ei==fi))&&(ei==ii))&&(mi==qi))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match in the 1st row and the 4th column!
else if (((((ci==di)&&(ei==fi))&&(fi==ji))&&(ni==ri))){
System.out.println("You won $" + x[0] + x[1]);}
// If that dosen't work check if numbers match in the 1st row and diagonally starting from the last number on the 1st row!
else if (((((ci==di)&&(ei==fi))&&(fi==ii))&&(li==oi))){
System.out.println("You won $" + x[0] + x[1]);}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// If that dosen't work check if numbers match in the 1st row!
else if ((ci==di)&&(ei==fi)){
System.out.println("You won $" +x[0]);}
// If that dosen't work check if numbers match in the 1st column!
else if ((ci==gi)&&(ki==oi)){
System.out.println("You won $" +x[0]);}
// If that dosen't work check if numbers match diagonally starting from the 1st number!
else if ((ci==hi)&&(mi==ri)){
System.out.println("You won $" +x[0]);}
// If that dosen't work check if numbers match in the 2nd column!
else if ((di==hi)&&(li==pi)){
System.out.println("You won $" +x[0]);}
// If that dosen't work check if numbers match in the 3rd column!
else if ((ei==ii)&&(mi==qi)){
System.out.println("You won $" +x[0]);}
// If that dosen't work check if numbers match in the 4th column!
else if ((fi==ji)&&(ni==ri)){
System.out.println("You won $" +x[0]);}
// If that dosen't work check if numbers match diagonally starting from the last number on the 1st row!
else if ((fi==ii)&&(li==oi)){
System.out.println("You won $" +x[0]);}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// If that dosen't work check if numbers match diagonally starting from the last number on the 1st row!
else {
System.out.println ("You are officialy the unluckiest person ever! Just leave and get yourself a 4 leaf clover and never come back! Hmph Bad Luck");}
System.out.println("Please enter in 100 if you want to start over");
b=reader.readLine();
bi=Integer.parseInt(b);
}
if
(bi!=100
)
System.out.println("Loser Run Again and enter in 100! Ha you just lost your money to the machine! I don't care if you entered in 101 or 99 enter in 100");
}
}
Thanks again!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|