0% found this document useful (0 votes)
163 views1 page

Prog Tutorial1 PDF

The document outlines two tutorials for an object-oriented programming class, the first on composition and inheritance using classes like Text, Person, File, and Email, and the second on defining classes for a medical clinic like Patient, Doctor, and Billing to model patient and billing records. It provides details on the member variables and functions to implement for each class, and instructs to write a main function to demonstrate the classes by creating objects and using their methods.

Uploaded by

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

Prog Tutorial1 PDF

The document outlines two tutorials for an object-oriented programming class, the first on composition and inheritance using classes like Text, Person, File, and Email, and the second on defining classes for a medical clinic like Patient, Doctor, and Billing to model patient and billing records. It provides details on the member variables and functions to implement for each class, and instructs to write a main function to demonstrate the classes by creating objects and using their methods.

Uploaded by

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

KIE1008 (Programming Tutorial) Session 2016/2017 (Semester 2)

Tutorial 1: Object-Oriented Programming (Composition and Inheritance)

1. Define a class called Text that contains a member variable of type string named text that
stores any textual content for the document. Create the appropriate accessor and mutator
functions.

Class Person that contains member name. Create three constructor functions: Person() and
Person(name). Also create the getName() and setName() functions.

Next, define a class for File that is derived from Text and includes member variables for the
pathname (type String) and author (type Person). Implement appropriate accessor and
mutator.

Next, define a class for Email that includes member variables for the sender, recipient,
title and Text of an email message. Implement appropriate accessor and mutator functions.

Finally, create several sample objects of type Email and File in your main function, and
demonstrate their applications.

Also, use the following function to search for a specific keyword in the object:
bool containKeyword(const Text& obj, string keyword) {
if (obj.getText().find(keyword)!= string::npos)
return true;
return false;
}

[Google to understand this function]

2. Give the definition of two classes: Patient and Billing, whose objects are records for a clinic.
Patient will be derived from the class Person. Patient records the patient’s name and primary
physician, of type Doctor.

Class Person that contains member name. Create three constructor functions: Person(),
Person (name) and Person(const Person&). Also create the getName() and
setName() functions.

The Doctor class is derived from class Person as well, and also record the doctor’s specialty
(“Pediatrician”, “Obstetrician”, “General Practitioner” etc), and office visit fee.
A Billing object contains a Patient object and a Doctor object, and an amount due.

Be sure all your classes have a reasonable complement of constructors and accessor functions,
and an overloaded assignment operator, and a copy constructor.

Write a main function that contains several objects of each class to demonstrate every functions.

--END--

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy