0% found this document useful (0 votes)
10 views

Object Passing Lab

The document outlines the requirements for Lab 4, focusing on object-oriented programming concepts such as encapsulation, constructors, and methods for various classes including Rectangle, Point, Student, Book, and University. Each class must implement specific data members and methods, including copy constructors and comparison methods. The tasks emphasize creating and manipulating objects while ensuring proper encapsulation and functionality.

Uploaded by

idrhabib5
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Object Passing Lab

The document outlines the requirements for Lab 4, focusing on object-oriented programming concepts such as encapsulation, constructors, and methods for various classes including Rectangle, Point, Student, Book, and University. Each class must implement specific data members and methods, including copy constructors and comparison methods. The tasks emphasize creating and manipulating objects while ensuring proper encapsulation and functionality.

Uploaded by

idrhabib5
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab 4 – Object Passing

Note:
Add copy constructor and equals method in all questions.

Use this operator in copy constructor and object passing methods.

1. Create an encapsulated class Rectangle with length and width as data members. Create
a. Default constructor
b. One- argument constructor
c. two- argument constructor
d. display ()
e. calculateArea ()
f. checkSquare()
g. CompareArea(?) //compares two objects and returns the object with larger area.

2. Create an encapsulated class Point class with x and y as data members. Create
a. Default constructor
b. One- argument constructor (for x)
c. two- argument constructor
d. display()
e. move()
f. checkOrigin()
g. AddTwoPoints(Point pa)// Creates and returns a new point from two other
points
h. AddThreePoints( ???)

3. Create an Encapsulated class Student with following:


Data Members:
a. String Name
b. Int [] Result_array[5] // Result array contains the marks for 5 subjects
Methods:
a. Default constructor
b. One- argument constructor (for Name)
c. two- argument constructor
d. Average ( ??? ) // it returns the average based on the marks in the array.
e. CompareAverage(?) //compares Average of two students

5. Create an Encapsulated class Book.


a. Its data members are
i. author
ii. chapterNames[5]

Methods:
a. Default constructor
b. two- argument constructor
c. Create a method compareAuthors that compares the author of two Books and
returns true if both books have same author and false otherwise. (This method
Must manipulate two Book objects)

d. Create a method compareChapters that compares the chapters of two books


and returns true if both books have same chapters and false otherwise. (This
method Must manipulate two Book objects)

6. Create a class “University” having following characteristics:


Data Members:
 String uniName;
 String rectorName,
 String location;
 String departments[20]; // it’s a string array
Constructors:
 No argument. {Initialize department array with five values}
 A Constructor setting values of all parameters.
Methods:
1. Set methods for all Data Members
2. Get methods for all data members
3. Display
o This methods displays all the data members of the class
4. AddADepartment
o This method should ask the user for a new department name and add it in the
departments [] array.
5. CheckLocation //Boolean
o This method should check if a university is located in a particular city or not.
6. CompareDepartment(University u )// returns the university with larger number of
departments.

You might also like