finish homework2

Dependencies:   TextLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Car.h Source File

Car.h

00001 #ifndef _CAR_H_
00002 #define _CAR_H_
00003 
00004 #include "mbed.h"
00005 
00006 
00007 // The road is 100 meters long
00008 #define ROADLENGTH 100
00009 
00010 // Update is running at 1000ms (1 second cycles)
00011 #define TICK 1000
00012 
00013 class Car {
00014 public:
00015     int position; // Position, in meters, of the car
00016     int speed;    // Speed, in meters, of the car to be used to update the position next Update
00017     int tick;     // tick to show time passed 5 ticks is an update to speed
00018     
00019     // Add any other needed public attributes 
00020     // ...
00021     // ...
00022         
00023     // Constructor for the Car class
00024     // Modify as necessary to provide the Car object with
00025     // access additional resources
00026     Car(int id);
00027     
00028     // Update the position and speed of the car in a 1 second loop
00029     void update();
00030     
00031     // Reset the position of the car to 0 and set the speed to the given speed
00032     void reset(int speed);
00033     
00034     //
00035     int is_simulating();
00036 
00037   
00038 private:
00039     int id;         // Identifier so that we can distinguish between cars
00040     Thread* thread;  // Thread on which to run the car
00041     int simulation;
00042     void new_speed(void);
00043     void update_pos();
00044 
00045     // Add any other needed private attributes
00046     // ...
00047     // ... 
00048 };
00049 #endif