0% found this document useful (0 votes)
10 views2 pages

COMSATS University, Islamabad Department of Computer Science Assignment#1

This document outlines 5 questions for an assignment on object-oriented programming concepts in C++. It involves creating classes to represent books, a calculator, geometric shapes, addresses, and people. The deadline for the assignment is March 4, 2023. Students are asked to create encapsulated classes with constructors, methods to compare and manipulate objects, immutable classes, arrays of objects, inheritance between classes, and functions to check relationships between class attributes.

Uploaded by

xigon53558
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

COMSATS University, Islamabad Department of Computer Science Assignment#1

This document outlines 5 questions for an assignment on object-oriented programming concepts in C++. It involves creating classes to represent books, a calculator, geometric shapes, addresses, and people. The deadline for the assignment is March 4, 2023. Students are asked to create encapsulated classes with constructors, methods to compare and manipulate objects, immutable classes, arrays of objects, inheritance between classes, and functions to check relationships between class attributes.

Uploaded by

xigon53558
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

COMSATS University, Islamabad

Department of Computer Science


Assignment#1

Deadline: 03/04/2023
Mapped to CLO4

Q1 Create an Encapsulated class Book with data members, author and chapterNames[5]

 Create two overloaded constructors, one with no argument and one with two arguments.
 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)
 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)
 Create a method compareChaptersLength that compares the chapters of two books and
returns the books with larger chapters. (This method Must manipulate two Book objects)
Note: All book objects will have five chapters

Q2 Create a Calculator class that has following methods:


 sum, multiply, divide, modulus , sin , cos , tan

The user should be able to call these methods without creating an object of Calculator class.

Q3 Convert the following class to immutable class: (I’ll provide this code on teams too)
Q4 Create a class Geometric collection.
 Create arrays of circle and rectangle of length 10 as data members
 Create default and argument constructor.
 Create display function.
 Create method to find area of Geometric collection.

Q5 Implement the following given scenario:


 Create a class Address with data members, home, street, and city.
 Create three constructors (default, argument and copy), set and get methods.
 Now create a class Person which contain “has-a” relation with Address class. It has data
members : firstName and LastName.
 Create constructors, set get methods and display function in Person Class.
 Create a function in Person class that returns true if he lives in “Islamabad” and false
otherwise.
 Create another class Book that contains an author of type Person. Other data members
are bookName and publisher. Give constructors and a display function that prints all
details of Book.
 Write a function in Book class that checks if the street number is less than 10. Return true
or false.
 Test class Book in main. Modify the address of the author in runner class.

You might also like