forked from sweskills/prog-method-assignment-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollectNewspaperKarel.java
57 lines (45 loc) · 1.21 KB
/
CollectNewspaperKarel.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
/*
* File: CollectNewspaperKarel.java
* --------------------------------
* At present, the CollectNewspaperKarel subclass does nothing.
* Your job in the assignment is to add the necessary code to
* instruct Karel to walk to the door of its house, pick up the
* newspaper (represented by a beeper, of course), and then return
* to its initial position in the upper left corner of the house.
*/
//
//
import stanford.karel.*;
public class CollectNewspaperKarel extends SuperKarel {
//The Program is to make Karel pick up the newspaper and return to its primary position
public void run() {
moveToTheNewspaper();
pickItUp();
returnToStartingPoint();
}
//Moves Karel from its position to the point where the Newspaper is
private void moveToTheNewspaper() {
// TODO Auto-generated method stub
move();
turnRight();
move();
turnLeft();
move();
move();
}
private void pickItUp() {
// TODO Auto-generated method stub
pickBeeper();
}
private void returnToStartingPoint() {
// TODO Auto-generated method stub
turnAround();
move();
turnRight();
move();
turnLeft();
move();
move();
turnAround();
}
}