Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

ClassesObject-Object Oriented Programming-Lecture Handout, Exercises of Object Oriented Programming

Objective of this cours is to develop effective computer programming skills in solving complex problems and to learn adequate and operational software organization in developing real life engineering solutions using powerful object oriented paradigm of the language. It includes: Include, Float, Private, Public, Return, Car, Maserati, Toyota, Distance, Check

Typology: Exercises

2011/2012

Uploaded on 07/31/2012

netu
netu 🇮🇳

4.5

(4)

55 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download ClassesObject-Object Oriented Programming-Lecture Handout and more Exercises Object Oriented Programming in PDF only on Docsity! 1c:\documents and settings\usman.younis\my documents... studio 2010\Projects\Classes\Classes\Classes.cpp # include < iostream > using namespace std ; float fuel _ price = 73 . 4 ; class Car { private : float fuel ; float mileage ; float distance ; public : Car () : fuel ( 0 . 0 ) , mileage ( 0 . 0 ) , distance ( 0 . 0 ) { } ~ Car () { } void re _ fuel ( float a ) ; void check _ fuel () ; void set _ mileage ( float b ) ; void drive ( float dist ) ; void check _ distance () ; void dump _ fuel ( Car ) ; }; void Car :: re _ fuel ( float a ) { fuel = a / fuel _ price ; } void Car :: check _ fuel () { cout << " Your car has : " << fuel << " litres left " << endl ; } void Car :: set _ mileage ( float b ) { mileage = b ; } void Car :: drive ( float dist ) { if (( dist / mileage ) > fuel ) { cout << " You need to re ‐ fuel your car " << endl ; return ; } fuel ‐= ( dist / mileage ) ; distance += dist ; } void Car :: dump _ fuel ( Car a ) { fuel += a . fuel ; a . fuel += fuel ; } void Car :: check _ distance () { cout << " Your car has travelled : " << distance << " km " << endl ; } docsity.com