-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPeevish.java
87 lines (56 loc) · 1.13 KB
/
Peevish.java
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
85
86
87
import java.util.ArrayList;
public class Peevish
{
public static void main (String [] args)
{
ArrayList<Door> boxes = new ArrayList<Door>();
boxes.add(null);
for (int i = 1; i<=100; i++)
{
boxes.add(new Door());
}
for (int k = 1; k<100; k++)
{
for (int j = k; j<=100; j+=k)
{
// int f = ((k)*j);
boxes.get(j).changeState();
}
for (int q = 1; q<100; q++)
{
if (boxes.get(q).retunOpen() == true)
System.out.print("[] ");
else
System.out.print("X ");
}
System.out.println();
System.out.println();
}
}
}
class Door
{
private boolean isOpen;
// private int number;
//
public Door()
{
isOpen = false;
// number = aNumber;
}
public void changeState()
{
if (isOpen == false)
isOpen = true;
else
isOpen = false;
}
public boolean retunOpen()
{
return isOpen;
}
//public int getNumber()
//{
// return number;
// }
}