You are on page 1of 2

Object Oriented Programming - Fall 2020 

 
Assignment 01
Topic  classes in C++ , setter getters,access specifiers and constructors
Objective  Making students familiarize with classes and their implementations in C++ 
Deadline 10-11-2020

 
Tips:                                                                                                     
 Indent and comment your code properly 
 Use meaningful variable names   
 Plan your code carefully on a piece of paper before you implement it. 
 Write setters and getters for every attribute
 Write non-parameterized and parameterized constructors.

Note: Zero tolerance for plagiarism. Both parties (copied by and copied from) will be
awarded 0.

Task 1

Write a program to print the area and circumference of a circle. Create a class name as
Circle which has radius as private data member. Write setter, getter and constructors for the
class. Write a function to calculate area of the circle. Write a function to calculate the
circumference of the circle.
Create an object of class Circle in main and display its area and circumference.

Task 2
Create a class named as Date which has day(int), month(int), year(int) as private attributes.
Write setters and getters for each attribute. Also write a non-returning display function to
print the attributes.
Write a program to create two objects of date in main(). In one you have to ask user to enter
his birthDate and in other the currentDate. Display the birthdate and currentDate of the user
by display function. And then calculate age of the user from the objects and print it.

Task 3
Create a class Employee which has name, year of joining, salary, and address as private data
members. Write getter and setter for each attribute. Write non-parameterized and parameterized
constructors. Write a function to calculate the number of years of working for the employee. Write
a display function for displaying employee’s information as a single sentence e.g. “name has been
working since year of joining with a salary of salary PKR. Address of name is address”.

Create two objects of Employee in main and set values. Display their information and display the
number of years of working for each Employee.

You might also like