Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "string"
- class Transport {
- private:
- int speed;
- int price1km;
- protected:
- Transport() = default;
- Transport(int qspeed, int qprice) {
- speed = qspeed;
- price1km = qprice;
- }
- Transport(Transport&&) {}
- Transport(const Transport&) {}
- ~Transport() {}
- void printTransport() {
- std::cout << speed << std::endl << price1km << std::endl;
- }
- float time(int distance) {
- float timex = distance / speed;
- return timex;
- }
- float cost(int distance) {
- float costx = distance * price1km;
- return costx;
- }
- };
- class Auto : public Transport {
- private:
- int timeT;
- int costT;
- public:
- Auto() : Transport() {}
- Auto(int qspeed, int qprice) : Transport(qspeed, qprice) {}
- void printAuto(Auto& old, int distancex) {
- old.printTransport();
- timeT = old.time(distancex);
- costT = old.cost(distancex);
- std::cout << timeT << std::endl << costT << std::endl;
- }
- };
- class Bike : public Transport {
- private:
- int timeT;
- int costT;
- public:
- Bike() : Transport() {}
- Bike(int qspeed, int qprice) : Transport(qspeed, qprice) {}
- void printBike(Bike& old, int distancex) {
- old.printTransport();
- timeT = old.time(distancex);
- costT = old.cost(distancex);
- std::cout << timeT << std::endl << costT << std::endl;
- }
- };
- class Wagon : public Transport {
- private:
- int timeT;
- int costT;
- public:
- Wagon() : Transport() {}
- Wagon(int qspeed, int qprice) : Transport(qspeed, qprice) {}
- void printWagon(Wagon& old, int distancex) {
- old.printTransport();
- timeT = old.time(distancex);
- costT = old.cost(distancex);
- std::cout << timeT << std::endl << costT << std::endl;
- }
- };
- int main(){
- Auto kia(90, 10);
- Bike GT(25, 5);
- Wagon telega(10, 3);
- kia.printAuto(kia, 600);
- GT.printBike(GT, 30);
- telega.printWagon(telega, 10);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement