forked from thakurRashmi/Begineer_Friendly_Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobocode.java
More file actions
56 lines (52 loc) · 1.41 KB
/
Robocode.java
File metadata and controls
56 lines (52 loc) · 1.41 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
}
return HEIGHT;
}
origin: stackoverflow.com
Java Polymorphic method
public static void main(String[] args) {
EntertainmentRobot jim = new EntertainmentRobot(0.6, "SONY", "QRIO", "To live with you, make life fun and make you happy", 7.3);
HumanStudyRobot jeff = new HumanStudyRobot(1.5, "Kawada Industries", "HRP", "Study into human movement and perfrom a wide range of tasks", 58.0);
//System.out.println(jim);
//System.out.println(jeff);
//EntertainmentRobot jim = robot();
Scanner input = new Scanner(System.in);
startRobot(jim, input);
startRobot(jeff, input);
}
public static void startRobot(Robot robot, Scanner input) {
/*
* POLYMORPHIC METHOD
* Accept an object of type robot
* Scanner object
* Start the robot
* Get robot to undertake a task
* stop the robot
*/
robot.start();
robot.doTask();
robot.stop();`enter code here`
}
/**
* Returns the width of the robot measured in pixels.
*
* @return the width of the robot measured in pixels.
* @see #getHeight()
*/
public double getWidth() {
if (peer == null) {
uninitializedException();
}
return WIDTH;
}
/**
* Returns the height of the current battlefield measured in pixels.
*
* @return the height of the current battlefield measured in pixels.
*/
public double getBattleFieldHeight() {
if (peer != null) {
return peer.getBattleFieldHeight();
}
uninitializedException();
return 0; // never called
}