PS 5 Class and Object
PS 5 Class and Object
1. Design a class that holds the following personal data: name, address, age, and phone
number. Write appropriate accessor and mutator functions. Demonstrate the class by
writing a program that creates three instances of it. One instance should hold your
information, and the other two should hold your friends’ or family members’
information.
2. Design A class called DATE. The class should store a date in three integers: moth,
day, and year. There should be member functions to print the date in following forms:
a. 12/25/2024
b. December 25, 2024
c. 25 December 2024.
3. Write a class named EMPLOYEE that has the following member variables:
a. NAME: a string that holds employee’s name
b. idNumber: A int variable that holds the employee’s ID number,
c. Department: A string that holds the name of department.
d. Position: A string that holds the employee’s job title.
e. The class should have
i. function that stores values in these member variables
ii. function that return the values in these member variables.
iii. The program should store this data in the four objects and then display
he data for each employee.
4. Write a class named Car that has the following member variables:
a. yearModel . An int that holds the car’s year model.
b. make . A string that holds the make of the car.
c. speed . An int that holds the car’s current speed.
d. The class should have the following member functions.
i. Accessor: functions to get the values stored in an object’s yearModel,
make, and speed member variables.
ii. accelerate . The accelerate function should add 5 to the speed member
variable each time it is called.
iii. brake . The brake function should subtract 5 from the speed member
variable each time it is called.
e. Demonstrate the class in a program that creates a Car object, and then calls the
accelerate function five times. After each call to the accelerate function, get
the current speed of the car and display it. Then, call the brake function five
times. After each call to the brake function, get the current speed of the car
and display it.
5. Write a class named RetailItem that holds data about an item in a retail store. The
class should have the following member variables:
a. description . A string that holds a brief description of the item.
b. unitsOnHand . An int that holds the number of units currently in inventory.
c. price . A double that holds the item’s retail price.
d. Write a appropriate mutator functions that store values in these member
variables, and accessor functions that return the values in these member
variables. Once you have written the class, write a program that creates three