CSI 250L Lab 10, Spring 2012

American University of Science and Technology · Programming II Lab · 2 pages · Dr. Saeed Raheel

All CSI 250L files
CSI 250L Lab 10, Spring 2012, page 1

Stuck on a question? A tutor can walk you through it.

CSI 250L Lab 10, Spring 2012, page 2

More CSI 250L files

Show the text of this lab
American University of Science & Technology Department Of Computer Science CSI 250L – Computer Programming-II Lab Spring 2011/2012 Lab Work 10 Problem1: Write the definition and implementation of the following classes specifications. Registered_Vehicle Attribute s  Year: an integer to indicate the registration year.  Plnum: A String to indicate the license_plate number.  type: an integer that can have the value 1(private) or 2(public). Methods  Constructor .  Print .  Set and get Write a program to test your classes’ implementations. 1 Car Note that all cars are registered vehicles. Attributes  Brand: a string of characters to store the car brand name.  Color: a string of characters.  Model: an integer to specify the car model number.  Cost: a number to indicate the car basic cost.  count: to count all instantiated objects. Methods  Constructor.  Calculate_price: return the price of a car using the following Formula: Price = cost + 300$ if the type = 1. Price = cost + 200$ if type =2.  Get_totalprice: returns the value of Totalprice.  Print  Set and get Problem 2 : Write an inheritance hierarchy that enables polymorphism for the following classes: Insurance_Policy: an abstract base class that has the following method: Attributes (declared as protected):  policy_num: an integer to identify each insurance policy.  acc_p: to accumulate the price of all issued insurance policies. Methods:  Constructor.  Get_name( ): pure virtual method.  Calculate_price( ): pure virtual method.  Get_policy_num(): to return a policy number. II- Based on the above declared class write the implementation of the following classes. Medical-Insurance: a concrete class derived from Isurance_Policy. Attributes (declared as private):  degree: to classify the medical insurance type(1,2,or3).  name: a string to store the name of the insured person.  age: an integer to store the person age. Methods:  Constructor.  Get_name( ): returns the class name.  Calculate_price( ): return the policy price calculated as follow: cost + 20% if the person age is greater 40. the cost =(200$ for 1, 250$ for 2, 300$ for 3) Car-Insurance: a concrete class derived from the Insurance_Policy: Attributes (declared as private):  Kind: an integer(1,2)  Car_num: a string to store the insured car number.  Car_year: a number to indicate the car-manufacturing year. Methods:  Constructor.  Get_name( ): returns the class name.  Calculate_price( ): return the policy price calculated as follow: cost + 15% if the car was manufactured before the year 2000. the cost =(250$ for 1, 300$ for 2) II- write a driver program create N Insurance policies. The user should input the type of a policy and its corresponding attributes. 2