View difference between Paste ID: u3mNBTGm and EHzU41u5
SHOW: | | - or go back to the newest paste.
1
object CrapsVersionFinal extends App {
2
println("This is the Craps game. In order to win you must roll either a 7 or 11 on your first roll.")
3
println("If you roll a 2 first you lose. Anything else and you roll again.")
4
println("On any more rolls you undertake, you must roll the same number as the first roll to win.")
5
println("If you roll a 7 you lose. Anything else and you re-roll. Repeat ad-infinitum.")
6
println("Press enter to begin.")
7
var Cheater = readLine();
8
println();
9
var RepeatGame = false
10
var Wins = 0
11
var Losses = 0
12
def printWandL()	{
13
  println("Total Wins: "+Wins+"")
14-
  println("Tota Losses: "+Losses+"")
14+
  println("Total Losses: "+Losses+"")
15
}
16
if (Cheater.equalsIgnoreCase("I want to be a winner"))	{
17
  var Cheats = true
18
  Wins = 1000000
19
  Losses = 0
20
  do	{
21
	  printWandL();
22
	  var resultRollOne = 3
23
	  var resultRollTwo = 4
24
	  var Total = resultRollOne+resultRollTwo
25
	  Wins += 1
26-
	  Wins = Wins + 1
26+
27
	  println("Play again? Y/N.")
28
	  var Response = readLine();
29
	  if (Response.equalsIgnoreCase("Yes")	|| Response.equalsIgnoreCase("Y")	|| Response.equalsIgnoreCase("Yes."))	{
30
	    Cheats = true
31
	    println("Press enter to roll again.")
32
	    readLine();
33
	  }
34
	  else	{
35
	    Cheats = false
36
	    println("Game terminated. You sure are a winner.")
37
	    printWandL();
38
	    var exit = true
39
	    while(exit == true)	{	      
40
	    }
41
	  }
42
  }
43
  while (Cheats == true)
44
}
45
do {
46
	printWandL();
47
	var number = 6
48
	def DiceRoll():Long = {
49
	  var Roll = Math.round(Math.random()*number)
50
	  if (Roll == 0)	{
51
		var IsZero = true
52
		while (IsZero == true)	{
53
			Roll = Math.round(Math.random()*number)
54
			if (Roll != 0)	{
55
				IsZero = false
56
				return Roll
57
			}
58
		}
59
	  }
60
	  else	{
61
	    return Roll
62
	  }
63
	  return 1
64
	}
65
	var resultRollOne = DiceRoll();
66
	var resultRollTwo = DiceRoll();
67
	var Total = resultRollOne + resultRollTwo
68
	var StoredTotal = Total
69
	if (Total == 7 || Total == 11)	{
70
		Wins += 1
71
		println("You rolled a "+resultRollOne+" and a "+resultRollTwo+", your total is "+Total+", therefore you win.")
72
		println("Play again? Y/N.")
73
		var Response = readLine();
74
		if (Response.equalsIgnoreCase("Y") || Response.equalsIgnoreCase("Yes"))	{
75
		  RepeatGame = true
76
		}
77
		else	{
78
		  println("Game terminated. Have a nice day.")
79
		  printWandL();
80
		  RepeatGame = false
81-
		Wins = Wins + 1
81+
82
	}
83
	else if (Total == 2)	{
84
	  Losses += 1
85
	  println("You rolled a "+resultRollOne+" and a "+resultRollTwo+", your total is "+Total+", therefore you lose.")
86
	  println("Play again? Y/N.")
87
	  var Response = readLine();
88
	  	if (Response.equalsIgnoreCase("Y") || Response.equalsIgnoreCase("Yes"))	{
89
	  		RepeatGame = true
90
		}
91
	  else	{
92
		  	println("Game terminated. Have a nice day.")
93
		  	printWandL();
94
		  	RepeatGame = false
95-
	  Losses = Losses + 1
95+
96
	}
97
	else	{
98
	  var RepeatGameTwo = true
99
	  println("You rolled a "+resultRollOne+" and a "+resultRollTwo+", your total is "+Total+", which results in no win nor penalty.")
100
	  do	{
101
		  println("Press enter to roll again.")
102
		  readLine();
103
		  resultRollOne = DiceRoll();
104
		  resultRollTwo = DiceRoll();
105
		  Total = resultRollOne + resultRollTwo
106
		  if (StoredTotal == Total)	{
107
			  Wins += 1
108
			  println("You rolled a "+resultRollOne+" and a "+resultRollTwo+".")
109
			  println("Your second roll was the same as the first ("+Total+"), therefore you win.")
110
			  println("Play again? Y/N.")
111
			  var Response = readLine();
112
			  if (Response.equalsIgnoreCase("Y") || Response.equalsIgnoreCase("Yes"))	{
113
				  RepeatGame = true
114
				  RepeatGameTwo = false
115
		}
116
			  else	{
117
				  println("Game terminated. Have a nice day.")
118
				  printWandL();
119
				  RepeatGame = false
120
				  RepeatGameTwo = false
121-
			  Wins = Wins + 1
121+
122
		  }
123
		  else if (Total == 7)	{
124
			  StoredTotal = 0
125
			  Losses += 1
126
			  println("You rolled a "+resultRollOne+" and a "+resultRollTwo+", your total is "+Total+", therefore you lose.")
127
			  println("Play again? Y/N.")
128
			  var Response = readLine();
129
			  if (Response.equalsIgnoreCase("Y") || Response.equalsIgnoreCase("Yes"))	{
130
				  RepeatGame = true
131
				  RepeatGameTwo = false
132
			  }
133
			  else	{
134
				  println("Game terminated. Have a nice day.")
135
				  printWandL();
136
				  RepeatGame = false
137
				  RepeatGameTwo = false
138-
			  Losses = Losses + 1
138+
139
		  }
140
		  else	{
141
			  println("You rolled a "+resultRollOne+" and a "+resultRollTwo+", your total is "+Total+", which results in no win nor penalty.")
142
	  }
143
	  }
144
	  while (RepeatGameTwo == true)
145
}
146
}
147
while (RepeatGame == true)
148
}