0% found this document useful (1 vote)
380 views10 pages

Oop Lab Final Paper of 2nd Sismeter

The document contains instructions for a final exam in Object Oriented Programming. It provides information such as the course code, title, date, duration, teacher, and student details. It also lists instructions for candidates regarding writing details on answer sheets, solving the paper in their own words to avoid plagiarism, submitting answer sheets on the learning management system by the due date and time, and consequences for late or incorrect submissions. The code section defines a base Car class and derived BMW class with getter and setter methods to access private data members and a main function to create a BMW object and call its methods to output vehicle details.

Uploaded by

Ubaid Khan
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 (1 vote)
380 views10 pages

Oop Lab Final Paper of 2nd Sismeter

The document contains instructions for a final exam in Object Oriented Programming. It provides information such as the course code, title, date, duration, teacher, and student details. It also lists instructions for candidates regarding writing details on answer sheets, solving the paper in their own words to avoid plagiarism, submitting answer sheets on the learning management system by the due date and time, and consequences for late or incorrect submissions. The code section defines a base Car class and derived BMW class with getter and setter methods to access private data members and a main function to create a BMW object and call its methods to output vehicle details.

Uploaded by

Ubaid Khan
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/ 10

1|Page

Department Computer Science


Program Name BS SE

Examination Final Term (2021 Spring)


Course Code CSC-205(L)
Course Title Object Oriented Programming
Exam Date 28/6/21
Exam Time (9:00 a.m.—2:00 p.m.)
Duration 5 Hours
Maximum Marks 50
Teacher Name Sohail Ilyas

Student Name Ubaid Ur Rehman


Section Student Id
SC 12105
(if any)
INSTRUCTIONS TO CANDIDATES
 Write your Student ID, Name and Section clearly on any of your answer books.
 Use A4 Size plain or lined sheets.
 Write the same question number on answer book / sheet as mentioned on question paper.
 Solve the paper in your own words because if paper grader reports copying/ cheating, your paper will
be cancelled and UFM case will be initiated against you.
 In case answers of two or more students match, their paper will be cancelled and UFM case will be
initiated against each student.
 You are required to submit solved answer book/sheet on LMS as per prescribed date and time.
 Submission of papers on LMS is compulsory, however e-mail your paper “To:”
[email protected] and “cc:” [email protected]
 In case of sending papers to wrong email, no further chances will be given.
 Anyone failing to submit his/ her answer book/ sheet on specified time as per his/ her exam date sheet
will be declared ABSENT and late submissions will not be accepted in any case.
2|Page

Code of the given program:

// ID 12105; Name Ubaid Ur Rehman:

#include<iostream>

using namespace std;

class Car{ // Base class

private: // Private data members of the base class

string Model_of_the_car;

string Brand_of_the_car;

double Price_of_the_car;

int Built_year;

double Final_price;

string Fuel_type;

public: // Getter and setter functions for base class


data members

void set_Model(string Model){

Model_of_the_car = Model;

}
3|Page

void set_Brand(string Brand){

Brand_of_the_car = Brand;

void set_Price(double Price){

Price_of_the_car = Price;

void set_Built(double Built){

Built_year = Built;

void set_FinalPrice(double Final){

Final_price = Final;

void set_FuelType(string Fuel) {

Fuel_type = Fuel;

string get_Model() {

return Model_of_the_car;
4|Page

string get_Brand() {

return Brand_of_the_car ;

double get_Price() {

return Price_of_the_car;

int get_Built() {

return Built_year;

double get_FinalPrice(){

return Final_price;

string set_FuelType(){

return Fuel_type;

};
5|Page

class BMW: public Car{ // Derived class of the base class

private: // Private data members of the derived


class

string PassengerAirBag="NO";

string AlloyWheels="NO";

int number_of_AI_modules=0;

public:

int counter=1;

BMW(){ // Constructor in derived class that


will provide values to

set_Model("BMWX1"); // all the data members of


base class

set_Brand("BMW");

set_Price(22000);

set_Built(2019);

set_FinalPrice(112500);

set_FuelType("Petrol");
6|Page

template<class M> double Get_Final(M var){

if(var>25000){

double Final_price=get_FinalPrice();

Final_price=Final_price+var;

return Final_price;

else{

double Final_price=get_FinalPrice();

return Final_price;

int shiftGear(){

counter++;

if(counter<5){

return counter;

}
7|Page

else{

counter=0;

void set_PassengerAirBag(){

PassengerAirBag ="Yes included";

void set_AlloyWheels(){

AlloyWheels ="Yes included";

void set_number_of_AI_modules(){

number_of_AI_modules =4;

string get_PassengerAirBag(){

return PassengerAirBag;

string get_AlloyWheels(){
8|Page

return AlloyWheels;

int get_number_of_AI_modules(){

return number_of_AI_modules;

void get_data(){

cout<<"***DETAIL OF THE CAR***"<<endl<<endl;

cout<<"Model of the car is : "<<get_Model()<<endl;

cout<<"Brand of the car is : "<<get_Brand()<<endl;

cout<<"price of the car with out tax :


"<<get_Price()<<endl;

cout<<"Built year of the car is : "<<get_Built()<<endl;

cout<<"Final price of the car is :


"<<Get_Final<double>(24000)<<endl;

cout<<endl<<endl;

cout<<"Passenger air bags included :


"<<get_PassengerAirBag()<<endl;
9|Page

cout<<"Allow wheels included : "<<


get_AlloyWheels()<<endl;

cout<<"Number Ai modules included : "<<


get_number_of_AI_modules()<<endl;

cout<<"How many types user have shift the gear : "<<


shiftGear()<<endl;

};

int main(){

BMW object;

object.set_AlloyWheels();

object.shiftGear();

object.shiftGear();

object.set_PassengerAirBag();

object.set_number_of_AI_modules();

object.get_data();

}
10 | P a g e

Output of the code:

You might also like