0% found this document useful (0 votes)
42 views7 pages

Assignment No 2

The document contains three programming tasks related to object-oriented programming in C++. Task 1 defines a Circle class with methods to set properties and calculate area and circumference. Tasks 2 and 3 define Vehicle and its derived classes (Truck and Car/SportsCar) with various attributes and methods to retrieve information about vehicles.

Uploaded by

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

Assignment No 2

The document contains three programming tasks related to object-oriented programming in C++. Task 1 defines a Circle class with methods to set properties and calculate area and circumference. Tasks 2 and 3 define Vehicle and its derived classes (Truck and Car/SportsCar) with various attributes and methods to retrieve information about vehicles.

Uploaded by

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

Assignment # 2

// SAP ID : 70110717

// Name : Adeel fazil

// Submitted To : Maria bibi

TASK NO 1:

//#include <iostream>

//using namespace std;

//class Circle {

//private:

// double x;

// double y;

// double radius;

//

//public:

// Circle() : x(0), y(0), radius(1) {}

//

// Circle(double x, double y) : x(x), y(y), radius(1) {}

//

// Circle(double x, double y, double radius) : x(x), y(y), radius(radius) {}

//

// void SetCenter(double x, double y) {

// this->x = x;

// this->y = y;

// }

//

// void SetRadius(double radius) {


// this->radius = radius;

// }

//

// double GetXCoordinate() const {

// return x;

// }

//

// double GetYCoordinate() const {

// return y;

// }

//

// double GetRadius() const {

// return radius;

// }

//

// double GetArea() const {

// return 3.1415926 * radius * radius;

// }

//

// double GetCircumference() const {

// return 2 * 3.1415926 * radius;

// }

//

// ~Circle() {

// std::cout << "Circle with center at (" << x << "," << y << ") radius=" << radius << " is destroyed" <<
std::endl;

// }

//};
//

//int main() {

// Circle circle1;

// Circle circle2(1, 2);

// Circle circle3(3, 4, 5);

//

// circle2.SetCenter(5, 6);

// circle3.SetRadius(10);

//

// std::cout << "Area of circle1: " << circle1.GetArea() << ", Circumference: " <<
circle1.GetCircumference() << std::endl;

// std::cout << "Area of circle2: " << circle2.GetArea() << ", Circumference: " <<
circle2.GetCircumference() << std::endl;

// std::cout << "Area of circle3: " << circle3.GetArea() << ", Circumference: " <<
circle3.GetCircumference() << std::endl;

//

// return 0;

//}

TASK NO 2:

//#include <iostream>

//using namespace std;

//

//class Vehicle {

//protected:

// string manufacturer;

// int cylinders;

// string owner;

//
//public:

// Vehicle(string manufacturer, int cylinders, string owner)

// : manufacturer(manufacturer), cylinders(cylinders), owner(owner) {}

//

// string getManufacturer() { return manufacturer; }

// int getCylinders() { return cylinders; }

// string getOwner() { return owner; }

//};

//

//class Truck : public Vehicle {

//private:

// float loadCapacity;

// int towingCapacity;

//

//public:

// Truck(string manufacturer, int cylinders, string owner, float loadCapacity, int towingCapacity)

// : Vehicle(manufacturer, cylinders, owner), loadCapacity(loadCapacity),


towingCapacity(towingCapacity) {}

//

// float getLoadCapacity() { return loadCapacity; }

// int getTowingCapacity() { return towingCapacity; }

//};

//

//int main() {

// Truck truck1("Audi", 8, "Luke", 10, 8000);

// Truck truck2("Ferrari", 6, "Luke", 5, 14000);

//
// cout << "Truck 1: manufacturer=" << truck1.getManufacturer() << ", cylinders=" <<
truck1.getCylinders()

// << ", owner=" << truck1.getOwner() << ", load capacity=" << truck1.getLoadCapacity()

// << ", towing capacity=" << truck1.getTowingCapacity() << endl;

//

// cout << "Truck 2: manufacturer=" << truck2.getManufacturer() << ", cylinders=" <<
truck2.getCylinders()

// << ", owner=" << truck2.getOwner() << ", load capacity=" << truck2.getLoadCapacity()

// << ", towing capacity=" << truck2.getTowingCapacity() << endl;

//

// return 0;

//}

TASK NO 3:

//#include <iostream>

//using namespace std;

//class Vehicle {

//protected:

// string manufacturer;

// int cylinders;

// string owner;

//public:

// Vehicle(string manufacturer, int cylinders, string owner)

// : manufacturer(manufacturer), cylinders(cylinders), owner(owner) {}

// string getManufacturer() { return manufacturer; }

// int getCylinders() { return cylinders; }

// string getOwner() { return owner; }

//};

//class Car : public Vehicle {


//private:

// int numberOfDoors;

// bool isConvertible;

//public:

// Car(string manufacturer, int cylinders, string owner, int numberOfDoors, bool isConvertible)

// : Vehicle(manufacturer, cylinders, owner), numberOfDoors(numberOfDoors),


isConvertible(isConvertible) {}

// int getNumberOfDoors() { return numberOfDoors; }

// bool isConvertible() { return isConvertible; }

//};

//

//class SportsCar : public Car {

//private:

// int horsepower;

// int topSpeed;

//

//public:

// SportsCar(string manufacturer, int cylinders, string owner, int numberOfDoors, bool isConvertible, int
horsepower, int topSpeed)

// : Car(manufacturer, cylinders, owner, numberOfDoors, isConvertible), horsepower(horsepower),


topSpeed(topSpeed) {}

//

// int getHorsepower() { return horsepower; }

// int getTopSpeed() { return topSpeed; }

//};

//

//int main() {

// SportsCar sportsCar1("Lamborghini", 12, "John Doe", 2, true, 700, 200);


// SportsCar sportsCar2("Ferrari", 8, "Jane Doe", 2, true, 800, 250);

//

// cout << "SportsCar 1: manufacturer=" << sportsCar1.getManufacturer() << ", cylinders=" <<
sportsCar1.getCylinders()

// << ", owner=" << sportsCar1.getOwner() << ", number of doors=" <<
sportsCar1.getNumberOfDoors()

// << ", is convertible=" << sportsCar1.isConvertible() << ", horsepower=" <<


sportsCar1.getHorsepower()

// << ", top speed=" << sportsCar1.getTopSpeed() << endl;

//

// cout << "SportsCar 2: manufacturer=" << sportsCar2.getManufacturer() << ", cylinders=" <<
sportsCar2.getCylinders()

// << ", owner=" << sportsCar2.getOwner() << ", number of doors=" <<
sportsCar2.getNumberOfDoors()

// << ", is convertible=" << sportsCar2.isConvertible() << ", horsepower=" <<


sportsCar2.getHorsepower()

// << ", top speed=" << sportsCar2.getTopSpeed() << endl;

//

// return 0;

//}

You might also like