I really need help making a c program for this The Parking G

I really need help making a c++ program for this.

The Parking Garage The CSC326 Parking Garage contains 2 lanes, each capable of holding up to 10 cars. There is only a single entrance/exit to the garage at one end of the lanes. If a customer arrives to pick up a car which is not nearest the exit, all cars blocking the cars\' path are moved into the other lane. If more cars still must be moved out of the way, they go into the street. When the customer\'s car is driven out, all cars in the street must be put back into the garage. Write a C++ program that reads input from either a file (that you create). Each line in the file contain two fields separated by a blank: a code (A = an arriving car, or D= a car wishes to depart) and a license plate number (this could be a string). Cars are assumed to arrive and depart in the order specified by the input. The program should print a message whenever a car arrives or departs. When a car arrives, the message should specify whether or not there is room in the garage for the car. If there is no room, the car leaves without entering. When a car departs, the message should include the number of times the car had to be moved out of the way so that other cars could depart. Each move from one lane to the other counts as 1; each move to the street counts as 1; each move from the street to a lane counts as 1. Don\'t forget to check for screwy things - e.g. someone wanting a car that\'s not in the garage, trying to park a car but both lanes are full, trying to park a car when only one lane is full, etc. Your program should define objects from a \'lane\' class to represent the 2 lanes and the street. The lane class will contain three stack objects one for each lane and the street. Represent the cars in each lane using a car class. The car class can contain variables that hold its license plate, and the number of times it’s moved. You\'ll need methods for manipulating the cars in the lanes, e.g. search for a car in a lane, move a car from a lane to somewhere, and perhaps higher-level methods like arrive and depart and methods to handle your output. This is NOT a complete list of methods needed, so feel free to experiment and expand the class definitions as much as you like.

Solution

use this stack class, and need to creat Garage class.

/ file Stack.h

// array stack implementation

#ifndef Stackh

#define Stackh

#include <cstdlib>

template<class ParkingType>

class Parking {

   // LIFO objects

public:

   Parking(int MaxParkingSize = 10);

   ~Parking() { delete[] packing; }

   bool IsEmpty() const { return top == -1; }

   bool IsFull() const { return top == MaxTop; }

   ParkingType Top() const;

   void push(const ParkingType & x);

   void pop();

private:

   int top; // current top of stack

   int MaxTop; // max value for top

   ParkingType * parking; // element array

};

template<class ParkingType>

Stack< ParkingType>::Parking(int Max ParkingSize)

{

   //Pre: none\'

   //Post: Array of size ParkingSaize to implement stack

   // Parking constructor.

   MaxTop = MaxParkingSize - 1;

   parking = new ParkingType[MaxParkingSize];

   top = -1;

}

template<class ParkingType>

ParkingType Packing<ParkingType>::Top() const

{

   //Pre: Parking is not empty

   // Post: Returns top element.

   if (IsEmpty())

       throw logic_error(\"Top fails: Parking is empty\");// Top fails

   return Parking[top];

}

template<class ParkingType>

void Parking<ParkingType>::push(const ParkingType & x)

{

   //Pre: Parking is not full

   //Post: Push x to Parking.

   //       Parking has one more element

   if (IsFull()) throw logic_error(\"Push fails: full stack\"); // Push fails

   Parking[++top] = x;

}

template<class ParkingType>

void Packing<ParkingType>::pop()

{

   //Pre: Parking is not Empty

   //Post: Parking has one less element

   if (IsEmpty()) {

       throw logic_error(\"Pop fails: Parking is empty\");

   }; // Pop fails

   top--;

}

#endif

I really need help making a c++ program for this. The Parking Garage The CSC326 Parking Garage contains 2 lanes, each capable of holding up to 10 cars. There is
I really need help making a c++ program for this. The Parking Garage The CSC326 Parking Garage contains 2 lanes, each capable of holding up to 10 cars. There is
I really need help making a c++ program for this. The Parking Garage The CSC326 Parking Garage contains 2 lanes, each capable of holding up to 10 cars. There is

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site