forked from sensei-thundercleese/closet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSlots.java
More file actions
84 lines (56 loc) · 2.12 KB
/
Copy pathSlots.java
File metadata and controls
84 lines (56 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//class Slots
//simulates a slot machine in your very own terminal
public class Slots {
private static final String[] FRUITS = { "orange", "orange", "orange",
"lime", "lime", "lime",
"lemon", "lemon", "lemon",
"peach", "peach", "peach"};
private String[] _fruits;
/*=====================================
Slots() -- default constructor
pre: constant array FRUITS exists, has been initialized
post: mutable array _fruits contains same elements as FRUITS
=====================================*/
public Slots() {
// *** YOUR IMPLEMENTATION HERE ***
}
/*=====================================
String toString() -- overrides inherited toString()
pre:
post: returns String of elements in slots 0 thru 2, separated by tabs
=====================================*/
public String toString() {
// *** YOUR IMPLEMENTATION HERE ***
return ""; //placeholder to get past compiler
}
/*=====================================
void swap(int,int) -- array swap util fxn
pre: _fruits array exists
post: elements at indices i, j are swapped
=====================================*/
private void swap( int i, int j ) {
// *** YOUR IMPLEMENTATION HERE ***
}
/*=====================================
void spinOnce() -- simulate a pull of the slot machine lever
pre: _fruits is existing array
post: randomized order of elements in _fruits array
=====================================*/
public void spinOnce() {
// *** YOUR IMPLEMENTATION HERE ***
}
/*=====================================
boolean FTW() -- checks for a winning combo
pre: _fruits is existing array
post: returns true if first 3 slots represent winning combo,
false otherwise
=====================================*/
public boolean FTW() {
// *** YOUR IMPLEMENTATION HERE ***
return false; //placeholder to get past compiler
}
//main() method for testing
public static void main( String[] args ) {
// *** YOUR IMPLEMENTATION HERE ***
}
}//end class Slots