Professional Documents
Culture Documents
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. import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
91. import java.awt.Color;
92.
93. /**
94. * Write a description of class Winner here.
95. *
96. * @author (your name)
97. * @version (a version number or a date)
98. */
99. public class Winner extends World
100.
{
101.
/**
102.
* Constructor for objects of class Winner.
103.
*
104.
*/
105.
public Winner(String letter)
106.
{
107.
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
108.
super(600, 400, 1);
109.
110.
GreenfootImage bg = getBackground(); //getting the background image
111.
bg.setColor(Color.magenta);
112.
String text = "TIE";
113.
if ("o".equals(letter))
114.
{
115.
text = "Congratulations, O is the WINNER! Press ENTER to play again.";
116.
}
117.
else
118.
if ("x".equals(letter))
119.
{
120.
text = "Congratulations, X is the WINNER! Press ENTER to play again.";
121.
}
122.
else
123.
{
124.
text = "TIE. Press ENTER to play again.";
125.
}
126.
bg.drawString(text, 125, 200);
127.
}
128.
}