Biblioteca Java - Blame information for rev 3
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
3 | mihai | 1 | /* |
2 | * MotorController.java | ||
3 | */ | ||
4 | package lab.scd.fire.robot; | ||
5 | |||
6 | /** | ||
7 | * Class created by @author Mihai HULEA at Feb 23, 2005. | ||
8 | * | ||
9 | * This class is part of the labs project. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | public class MotorController extends Thread { | ||
14 | |||
15 | public MotorController(Plane dimension, | ||
16 | |||
17 | UserInterface UI, Robot robo) { // constructor | ||
18 | |||
19 | super (); | ||
20 | |||
21 | dim = dimension; | ||
22 | |||
23 | myInterface = UI; | ||
24 | |||
25 | myRobot = robo; | ||
26 | |||
27 | } | ||
28 | |||
29 | public void run () { | ||
30 | |||
31 | int position = 0; // initial position | ||
32 | |||
33 | int setting; | ||
34 | |||
35 | while(true) { | ||
36 | |||
37 | // Get new offset and update position. | ||
38 | |||
39 | setting = myInterface.newSetting(dim); | ||
40 | |||
41 | position = position + setting; | ||
42 | |||
43 | myRobot.move(dim, position); // move to position | ||
44 | |||
45 | } | ||
46 | |||
47 | } | ||
48 | |||
49 | private Plane dim; | ||
50 | |||
51 | private UserInterface myInterface; | ||
52 | |||
53 | private Robot myRobot; | ||
54 | |||
55 | } | ||
56 | |||
57 | class Robot { | ||
58 | |||
59 | // The interface to the Robot itself. | ||
60 | |||
61 | public void move (Plane dim, int pos) {} | ||
62 | |||
63 | // Other methods, not significant here. | ||
64 | |||
65 | } | ||
66 | |||
67 | class UserInterface { | ||
68 | |||
69 | // Allows the next position of the robot to be | ||
70 | |||
71 | // obtained from the operator. | ||
72 | |||
73 | public int newSetting (Plane dim) { return 0; } | ||
74 | |||
75 | } | ||
76 | |||
77 | class Plane{ | ||
78 | int planeId; | ||
79 | public Plane(int planeId){ | ||
80 | this.planeId = planeId; | ||
81 | } | ||
82 | } |