Skip to content
Snippets Groups Projects
Commit 41d7ff82 authored by Rudi Buss's avatar Rudi Buss
Browse files

Update Exercise 1 - Vehicle.txt

parent 0213d980
Branches main
No related tags found
No related merge requests found
Dear course participants,
Along with the course, I would like to work with you on a small program every week. In this way, you can practice the content you have learned right away. At the end of the week I will submit my solution to the exercise online. You can also comment on my solution or post your solution in the forum.
Here is the first task to repeat the content of the first part of the course:
Given is the following program:
#include <cstdlib>
#include <iostream>
using namespace std;
class Vehicle
{
private:
string brand;
string licencePlate;
int ps;
int constructionYear;
public:
void displayData() {
cout << "Brand: " << brand << endl;
cout << "Licence Plate: " << licencePlate << endl;
cout << "PS: " << ps << endl;
cout << "Construction Year: " << constructionYear << endl;
}
private:
string brand;
string licencePlate;
int ps;
int constructionYear;
public:
void displayData() {
cout << "Brand: " << brand << endl;
cout << "Licence Plate: " << licencePlate << endl;
cout << "PS: " << ps << endl;
cout << "Construction Year: " << constructionYear << endl;
}
};
int main(){
int main() {
system("pause");
return 0;
return 0;
};
......@@ -41,7 +33,5 @@ Modify and extend the program as follows:
- The program should have 3 classes: The program should have 3 classes: The base class Vehicle with already existing attributes, and 2 derived classes from the base class Vehicle: the class Car with an attribute maxSpeed of the data type float, and the class Truck with 2 attributes: maxLoad (float) and numberWheels (int).
- For each new created class, define both the default constructor and the constructor with a member initialization list, as well as a member function to output the data displaydata().
- Create an instance of class Car and Truck and display the data on the screen.
Hint: Develop the program step by step. Compile the program after each intermediate step and check the desired result.
Regards,
Barbara Handy
\ No newline at end of file
Hint: Develop the program step by step. Compile the program after each intermediate step and check the desired result.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment