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

Csc241oop Fa24bee3a A2

OOPS Assignment

Uploaded by

abubakar
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)
16 views2 pages

Csc241oop Fa24bee3a A2

OOPS Assignment

Uploaded by

abubakar
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 Electrical & Computer Engineering


CSC241 Object Oriented Programming
Assignment No. 02
[CLO-1 (C1)  PLO-1]
Program: BEE-3(A) Total Marks: 100
Semester: Fall 2024 Post Date: 8th Oct. 2024
Instructor: Dr. Riaz Hussain T.A.:
Due Date: Thursday, 17th Oct. 2024

Note: See the method for submission at the end.

I know you can find tons of implementations available on the internet, even at the end of the shared
URL. I request you to try these problems yourself. Take a small step at a time and gradually build. If
you are stuck at any point/error; think yourself, take a small break, discuss it with someone (may be
your instructor) and then again get back to the problem independently to get pass the hurdle. Spend
some time and debug; I also know that you can do it, and you will.

Question No. 1: [6 × 5 = 30]


a) Create a class called Date that includes three pieces of information as data members—
a month (type int), a day (type int) and a year (type int).
b) Your class should have a constructor with:
i. No arguments, initializing the date to 01/01/2000
ii. Three parameters that uses the parameters to initialize the three data members.
For the purpose of this exercise, assume that the values provided for the year and day
are correct, but ensure that the month value is in the range 1–12; if it isn’t, set the
month to 1.
c) Provide a set and a get function for each data member.
d) Provide a member function displayDate that displays the month, day and year separated
by forward slashes (/).
e) Write a test program that demonstrates class Date’s capabilities.

Question No. 2: [9 × 2 = 18]


a) Explain why a class might provide a set function and a get function for a data member.
b) Write a statement that sets the hrs member of the time2 structure variable equal to 11.
c) True or false: In a class you can have more than one constructor with the same name.
d) Member functions defined inside a class definition are ________ by default.
e) In a class definition, data or functions designated private are accessible
i. to any function in the program.
ii. only if you know the password.
iii. to member functions of that class.
iv. only to public members of the class.

Page 1 of 2 : Assignment-2 BEE-3A: Fall 2024: CSC241OOP Dr Riaz Hussain


f) The only technical difference between structures and classes in C++ is that _________.
g) Sending a message to an object is the same as _________.
h) If three objects of a class are defined, how many copies of that class’s data items are
stored in memory? How many copies of its member functions?
i) Write a declaration (not a definition) for a const void function called aFunc( ) that takes
one const argument called jerry of type float.

Question No. 3: [40 + 12]


Create a class called Ship that incorporates a ship’s number and location. Number each ship
object as it is created. Use two variables of the Angle class from Question-7 of exercise to
represent the ship’s latitude and longitude. A member function of the Ship class should get a
position from the user and store it in the object; another should report the serial number and
position. Write a main( ) program that creates three Ships, asks the user to input the position
of each, and then displays each ship’s number and position.

Construct the UML diagram of the class Ship.

To submit your work,

Join the class: https://onlinegdb.com/classroom/invite/wA_mPyJbC

Create a folder AssignmentNo-2

For each programming question create a project with appropriate name (preferably having
question number) within the folder (If needed can create subfolder for each programming
question.) and submit.

In the class, you will submit the hard copy with the cover page and URLs of all the
programming questions along with the description of the core concept, analysis and
observation. For questions requiring with no programming task submit the handwritten/typed
answer.

Don’t forget to submit the pdf on MS Teams on or before the due date. Note, the URLs must
be clickable.

Page 2 of 2 : Assignment-2 BEE-3A: Fall 2024: CSC241OOP Dr Riaz Hussain

You might also like