-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlay1.java
217 lines (145 loc) · 4.32 KB
/
Play1.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import java.io.*;
public class Play1
{
String np1;
String np2;
int l;int k;
int s1,s2;
int t1,t2;
String ch;
String w;
int l1=1; int l2=1;
String n1;String n2;
String w1;String w2;
String c1;String c2;
int p1;int p2;
int pos1; int pos2;
Play1(String x,String y,int p)
{
np1=x;
np2=y;
l=p;
k=l*10;
s1=s2=0;
t1=t2=1;
w="";
}
int Calculate1()
{
if(t1<=10)
{
l1=1;
c1="R";
p1=(t1+1);
}
else
{
if(t1>(10*l1))
l1++;
{
if(l1%2==0)
c1="L";
else
c1="R";
}
p1=(t1%10);
if(p1==0)
{ p1=10;}
if(c1=="L")
p1=((10-p1)+1);
else
p1=p1;
p1++;
}
return(p1);
}
int Calculate2()
{
if(t2<=10)
{
l2=1;
c2="R";
p2=(t2+1);
}
else
{
if(t2>(10*l2))
l2++;
{
if(l2%2==0)
c2="L";
else
c2="R";
}
p2=(t2%10);
if(p2==0)
{ p2=10;}
if(c2=="L")
p2=((10-p2)+1);
else
p2=p2;
p2++;
}
return(p2);
}
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(in);
private void Player()throws IOException
{
System.out.println(np1+".....Enter 'T/t' to throw Dice....");
ch=(br.readLine());
if(ch.equalsIgnoreCase("T"))
{
ThrowDice TD=new ThrowDice();
s1=TD.Throw(np1);
DisplayDice DD=new DisplayDice();
DD.displaydice(s1);
System.out.println("------------------------------------------------------"+"\n"+"\n"+"\n");
t1+=s1;
pos1=Calculate1();
pos2=Calculate2();
for(double a=0;a<500000000;a++)
{
}
Track TR1=new Track(np1,np2,pos1,pos2,c1,c2);
TR1.print();
for(double a=0;a<500000000;a++)
{
}
}
}
private void BlueJ()throws IOException
{
ThrowDice TD2=new ThrowDice();
s2=TD2.Throw(np2);
DisplayDice DD2=new DisplayDice();
DD2.displaydice(s2);
System.out.println("------------------------------------------------------"+"\n"+"\n"+"\n");
t2+=s2;
pos1=Calculate1();
pos2=Calculate2();
for(double a=0;a<500000000;a++)
{
}
Track TR2=new Track(np1,np2,pos1,pos2,c1,c2);
TR2.print();
for(double b=0;b<500000000;b++)
{
}
}
void Start()throws IOException
{
while((t1<=k)&&(t2<=k))
{
Player();
ch="";
BlueJ();
}
if(t1>t2)
w=np1;
else
w=np2;
Final fn=new Final(w);
fn.FinalDisplay();
}
}