0% found this document useful (0 votes)
7 views4 pages

1

Uploaded by

danishnawaz398
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

1

Uploaded by

danishnawaz398
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include <iostream>

#include "BilalMotors.h"
#include "Bike.h"
#include "Car.h"

using namespace std;

void ShowVehicles(const BilalMotors& motors) {


cout << "Number of Total Vehicles: " << motors.getNumVehicles() << endl;
cout << "-------------------------------------------------------------" <<
endl;
for (int i = 0; i < motors.getNumVehicles(); i++) {
motors.getVehicle(i)->display();
cout << "-------------------------------------------------------------" <<
endl;
}
}

int main() {
BilalMotors motors;

char choice;
do {
cout << "*** BILAL MOTORS ***" << endl;
cout << "S Show vehicles list (brief)" << endl;
cout << "E Create a data file (output file)" << endl;
cout << "A Add new vehicle" << endl;
cout << "B for Bike" << endl;
cout << "C for Car" << endl;
cout << "F Find Vehicle by type" << endl;
cout << "Q Quit Program" << endl;

cout << "Enter your choice: ";


cin >> choice;
cout << endl;

switch (choice) {
case 'S':
ShowVehicles(motors);
break;
case 'E':
char fileName[100];
cout << "Enter the output file name: ";
cin >> fileName;
if (motors.saveData(fileName)) {
cout << "Data saved to file successfully!" << endl;
} else {
cout << "Failed to save data to file!" << endl;
}
break;
case 'A':
char compName[100];
char color[100];
int numWheels;
int power;
char type[100];

cout << "Enter the company name: ";


cin.ignore(); // Ignore the newline character in the input buffer
cout << "Enter the color: ";
cin.getline(color, 100);
cout << "Enter the number of wheels: ";
cin >> numWheels;
cout << "Enter the power (CC): ";
cin >> power;
cin.ignore(); // Ignore the newline character in the input buffer
cout << "Enter the type (Bike/Car): ";
cin.getline(type, 100);

if (strcmp(type, "Bike") == 0) {
double height;
bool selfStart, discBrake;

cout << "Enter the height: ";


cin >> height;
cout << "Does it have self-start? (1 for Yes, 0 for No): ";
cin >> selfStart;
cout << "Does it have disc brake? (1 for Yes, 0 for No): ";
cin >> discBrake;

Bike* bike = new Bike(compName, color, numWheels, power, type,


height, selfStart, discBrake);
motors.addVehicle(bike);
} else if (strcmp(type, "Car") == 0) {
int noOfDoors, noOfSeats;
char transmission[100];

cout << "Enter the number of doors: ";


cin >> noOfDoors;
cin.ignore(); // Ignore the newline character in the input
buffer
cout << "Enter the transmission (automatic/manual): ";
cin.getline(transmission, 100);
cout << "Enter the number of seats: ";
cin >> noOfSeats;

Car* car = new Car(compName, color, numWheels, power, type,


noOfDoors, transmission, noOfSeats);
motors.addVehicle(car);
} else {
cout << "Invalid vehicle type!" << endl;
}
break;
case 'B':
{
char compName[100];
char color[100];
int numWheels;
int power;
double height;
bool selfStart, discBrake;

cin.ignore(); // Ignore the newline character in the input


buffer
cout << "Enter the company name: ";
cin.getline(compName, 100);
cout << "Enter the color: ";
cin.getline(color, 100);
cout << "Enter the number of wheels: ";
cin >> numWheels;
cout << "Enter the power (CC): ";
cin >> power;
cout << "Enter the height: ";
cin >> height;
cout << "Does it have self-start? (1 for Yes, 0 for No): ";
cin >> selfStart;
cout << "Does it have disc brake? (1 for Yes, 0 for No): ";
cin >> discBrake;

Bike* bike = new Bike(compName, color, numWheels, power,


"Bike", height, selfStart, discBrake);
motors.addVehicle(bike);
}
break;
case 'C':
{
char compName[100];
char color[100];
int numWheels;
int power;
int noOfDoors, noOfSeats;
char transmission[100];

cin.ignore(); // Ignore the newline character in the input


buffer
cout << "Enter the company name: ";
cin.getline(compName, 100);
cout << "Enter the color: ";
cin.getline(color, 100);
cout << "Enter the number of wheels: ";
cin >> numWheels;
cout << "Enter the power (CC): ";
cin >> power;
cin.ignore(); // Ignore the newline character in the input
buffer
cout << "Enter the number of doors: ";
cin >> noOfDoors;
cin.ignore(); // Ignore the newline character in the input
buffer
cout << "Enter the transmission (automatic/manual): ";
cin.getline(transmission, 100);
cout << "Enter the number of seats: ";
cin >> noOfSeats;

Car* car = new Car(compName, color, numWheels, power, "Car",


noOfDoors, transmission, noOfSeats);
motors.addVehicle(car);
}
break;
case 'F':
char searchType[100];
cin.ignore(); // Ignore the newline character in the input buffer
cout << "Enter the type of vehicle to search: ";
cin.getline(searchType, 100);
motors.searchVehicle(searchType);
break;
case 'Q':
cout << "Quitting the program..." << endl;
break;
default:
cout << "Invalid choice!" << endl;
break;
}

cout << endl;

} while (choice != 'Q');

return 0;
}

You might also like