24F0525 Oop6
24F0525 Oop6
LAB No: 6
Name: Muhammad Khalil
Section: BCS-2E
TASK : 2
Code:
#include <iostream>
#include <string>
using namespace std;
class vehicle
{
private:
string make;
string model;
int year;
double mileage;
public:
void display() {
cout << "Vehicle Details:" << endl;
cout << "Make: " << get_make() << endl;
cout << "Model: " << get_model() << endl;
cout << "Year: " << get_year() << endl;
cout << "Mileage: " << get_mileage() << " km" << endl;
}
};
int main() {
vehicle v1;
string make, model;
int year;
double mileage;
cin.ignore();
v1.display();
system("pause");
return 0;
}
Outpur:
TASK: 3
Code:
#include <iostream>
#include <string>
using namespace std;
class LibraryBook {
private:
string title;
string author;
string isbn;
int yearPublished;
bool available;
public:
LibraryBook() {
title = "";
author = "";
isbn = "";
yearPublished = 0;
available = true;
}
// Display Function
void display() {
cout << "\nBook Details:" << endl;
cout << "Title: " << get_title() << endl;
cout << "Author: " << get_author() << endl;
cout << "ISBN: " << get_isbn() << endl;
cout << "Year Published: " << get_yearPublished() << endl;
cout << "Available: " << (is_available() ? "Yes" : "No") << endl;
}
};
int main() {
LibraryBook book;
string title, author, isbn;
int year;
char avail;
book.display();
system("pause");
return 0;
}
Ouptut: