CSI 250L Lab 9, Spring 2012
American University of Science and Technology · Programming II Lab · 3 pages · Dr. Saeed Raheel
More CSI 250L files
- Lab 1 Solution · Spring 2012Lab · with solutionView
- Lab 1 · Spring 2012LabView
- Lab 10 Solution · Spring 2012Lab · with solutionView
- Lab 10 · Spring 2012LabView
- Lab 11 Solution · Spring 2012Lab · with solutionView
- Lab 11 · Spring 2012LabView
- Lab 12 Solution · Spring 2012Lab · with solutionView
- Lab 12 · Spring 2012LabView
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 9
Problem1:
Write the definition and implementation of the following classes specifications. Each
class definition and implementation should be written in a separate file.
II- Write a program to do the following steps in order:
Create a pointer, sptr, to point to an object of class Square that contain the
following values: side = 10, color = “Blue”, draw_style = “dotted”.
Output the values stored in sptr.
1
GraphicalObject
Attributes
color: a string of characters.
draw_style: a string of characters.
Methods
constructor (No default values)
destructor.
Set,get
print
Remarks
The color and draw_style attributes should store any
number of characters.
The class attributes should be accessible in a derived class
implementation.
Square
Note that a square is a GraphicalObject.
Attributes
side: an integer to specify the side length.
Count: for all instantiated objects
Methods
constructor (no default values).
destructor.
Compute area : returns the area of a square using the
formula area = side*side;
Set, get
print : to output all information about a square as follows:
color = orange
drawstyle = plain
side = 10
area = 100
Write the necessary statements to end the program.
Problem
2 :
Write the implementation of the following classes as specified below:
Address
Attributes
city: a String.
area: a String.
Methods
Constructors (the default constructor will initialize the
Address to spaces.
Print()
Teacher
Note that a teacher is an employee.
2
Employee
Attributes
ID: an integer to identify each employee.
fname: a String .
lname: a String.
address: to store the information about an employee
address.
rank: an integer to classify an employee position that can
be assigned only the values 1,2, or 3.
Methods
constructor (no default constructor).
print: to print information about an employee in the
following format:
4567 Imad Faraj lives in Beirut – Hamra, and has rank 2
get_rank: returns the rank of an employee .
Attributes
hours: an integer to store the number of hours taught by a
teacher.
totalsalary: an integer that is shared by all objects of the
class Teacher. It should accumulate the value of all
teachers’ salaries.
Methods
constructor.
Calculate_salary : return the salary of a teacher. Note
that the salary is equal to:
-hours * 75000 if rank =1.
-hours * 50000 if rank =2.
-hours * 40000 if rank =3.
get_totalsalary: returns the value of totalsalary.
print: to print information about a teacher as follows:
4239 Marwan Eid lives in Beirut – Zarif and has rank
2
Hours = 30, Salary = 1500000.
II- Write a driver program to instantiate N objects of the class Teacher. You should
output the information about the teacher with the highest salary.
3