Lab7: Modeling Vehicles

This is a group project!

With any luck, you should have your highway set up and maybe have a single car wandering along the highway. In this lab, we will create a bunch of cars to start filling the highway up like the real I35 through Austin.

We will build vehicles using a simple class, and manage the entire highway mess using a linked list. Here is the vwhicle class definition I used in the demo simulation. Feel free to modify it as you see fit:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once

class Vehicle {
    public:
        int size;       // how big should this vehicle be
        int xPos;       // screen position in pixels
        int yPos;       
        int xSpeed;     // current speed
        int ySpeed;

        int lane;
        int preferred_lane;
        bool active;
        int color;

        Vehicle();
        void setPosition( int x, int y );
        void setSpeed( int xv, int yv );

        void move( void );
};

The code you see here should get you thinking about how we want our cars to behave. For now, just add this code and see if you can get a collection of cars moving along.