-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErikaTran.java
More file actions
156 lines (140 loc) · 3.39 KB
/
Copy pathErikaTran.java
File metadata and controls
156 lines (140 loc) · 3.39 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
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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* ErikaTran is a student in AP CSA seating chart.
*
* @author Erika Tran
* @version August 2, 2020
*/
public class ErikaTran extends Student implements SpecialInterestOrHobby
{
/**
* ErikaTran constructor
*/
public ErikaTran(String f, String l, int r, int s) {
firstName=f;
lastName=l;
myRow=r;
mySeat=s;
portraitFile="erikatran.jpg";
standingFile="erikatran-standing.JPG";
soundFile="erikatran.wav";
setImage(portraitFile);
sitting = true;
}
/**
* Default constructor for ErikaTran.
*/
public ErikaTran() {
firstName="Erika";
lastName="Tran";
myRow=1;
mySeat=3;
portraitFile="erikatran.jpg";
standingFile="erikatran-standing.JPG";
soundFile="erikatran.wav";
setImage(portraitFile);
sitting = true;
}
/**
* Say name and move spin around when clicked on.
*/
public void act()
{
if(Greenfoot.mouseClicked(this)) {
sitting = false;
setImage(standingFile);
System.out.println("");
getName();
sayName();
myHobby("I like to bake!");
spin();
provideLesson();
sitDown();
}
}
/**
* Display name in the Terminal Window.
*/
public void getName()
{
System.out.println("My name is Erika Tran");
}
/**
* Say name
*/
public void sayName()
{
Greenfoot.playSound(soundFile);
}
/**
* Spin at the top of the class when Erika is clicked on.
*/
public void spin()
{
setLocation(0,0);
Greenfoot.delay(10);
for (int i=1;i<=9;i++){
setLocation(i,0);
Greenfoot.delay(10);
turn (90);
Greenfoot.delay(15);
}
Greenfoot.delay(15);
returnToSeat();
}
/**
* If wanted, provide lesson about variables.
*/
public void provideLesson()
{
while (! sitting) {
String q=Greenfoot.ask("Are you ready to start (yes/no)");
if (q.contains("yes")){
bluej.utility.Utility.openWebBrowser("https://tinyurl.com/variablesvideop2");
Greenfoot.delay(50);
q=Greenfoot.ask("May I sit down?");
if (q.contains("yes")){
Greenfoot.delay(10);
sitDown();
}
}
else {
q=Greenfoot.ask("I don't understand the question... May I sit down?");
}
if (q.contains("yes")){
Greenfoot.delay(10);
sitDown();
}
}
}
/**
* Answer questions the class may ask.
*/
public void answerQuestion()
{
}
/**
* Return to seat after you have spun at the top of class.
*/
public void returnToSeat()
{
setLocation(3,1);
setRotation(0);
}
/**
* Take seat and display sitting image.
*/
public void sitDown()
{
setLocation(3,1);
setRotation(0);
setImage(portraitFile);
sitting = true;
}
/**
* Display my hobby in the Terminal Window
*/
public void myHobby(String s) {
System.out.println(s);
}
}