-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp_random.java
More file actions
32 lines (30 loc) · 716 Bytes
/
Copy pathp_random.java
File metadata and controls
32 lines (30 loc) · 716 Bytes
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
class p_MainClass {
public static void main(String[] args) {
{
System.out.print("The value should be 1: ");
System.out.println(new RNG().Generate());
System.out.print("The value should be 1: ");
System.out.println(new BetterRNG().Generate());
System.out.print("The value should be 2: ");
System.out.println(new BetterRNG().BetterGenerate());
}
}
}
class RNG {
int x;
public int Generate() {
x = 3;
//y = 1;
return 1;
}
}
class BetterRNG extends RNG {
//int x;
//boolean x;
int y;
public int BetterGenerate() {
x = 3;
y = 1;
return 2;
}
}