0% found this document useful (0 votes)
22 views3 pages

Assignment 3: CS 115 001 - Object-Oriented Design Due: March 23, 2024

Uploaded by

imaanjot20
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)
22 views3 pages

Assignment 3: CS 115 001 - Object-Oriented Design Due: March 23, 2024

Uploaded by

imaanjot20
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/ 3

Assignment 3

CS 115 001 - Object-Oriented Design


Due: March 23, 2024

Instructions:
Your program should be written in C++. Please submit the source files for both exercises.

Marking Scheme:
1. Readability and programming style (10%): The program should be easy to read, well commented, structured
(i.e. should incorporate proper layout, indentation, white-spaces, etc.), and well designed (i.e. should follow
top-down design approach). Follow the commenting guidelines for interface specification provided in the
class/slides/notes.
2. Compiling and execution process (10%): The program must compile and execute without errors and warnings.
3. Correctness (80%): The program should produce correct results.

4. Sample-based marking might be practised for this assignment.

Questions (50 points each):


1. Consider the following interface of a class Entry.
c l a s s Entry {

s t r i n g name ; // The name o f a p e r s o n


s t r i n g number ; // The phone number o f t h e p e r s o n

public :
// D e f a u l t c o n s t r u c t o r t h a t i n i t i a l i z e s t h e name and
// t h e phone number t o an empty s t r i n g
Entry ( ) ;

// I n i t i a l i z i n g c o n s t r u c t o r t h a t i n i t i a l i z e s name t o
// s 1 and phone number t o s 2
Entry ( s t r i n g s1 , s t r i n g s 2 ) ;

// C o n s t r u c t o r t h a t i n i t i a l i z e s name t o s 1 and phone number


// t o an empty s t r i n g
Entry ( s t r i n g s 1 ) ;

1
// S t o r e s s 1 a s t h e name and s 2 a s t h e phone number i n t h e
// e n t r y o b j e c t
v o i d s e t E n t r y ( s t r i n g s1 , s t r i n g s 2 ) ;

// S t o r e s s 1 a s t h e name and ”416−xxx−xxxx ” a s t h e phone number


// i n t h e Entry o b j e c t
void setEntry ( s t r i n g s1 ) ;

s t r i n g getName ( ) ; // Returns t h e name o f t h e p e r s o n

s t r i n g getNumber ( ) ; // Returns t h e phone number o f t h e p e r s o n

// E q u a l i t y o p e r a t o r , c h e c k s i f two names a r e t h e same


// phone numbers can d i f f e r
b o o l o p e r a t o r == ( c o n s t Entry &e ) ;

// I n e q u a l i t y o p e r a t o r , c h e c k s i f two names a r e not t h e same


b o o l o p e r a t o r != ( c o n s t Entry &e ) ;
}

Please implement each member function and test your program. A sample testing is shown below.
v o i d main ( ) {
Entry e1 , e2 ( ” S o t i r i o s ” ) , e3 ( ” Yves ” , ” ” ) , e4 ( ” y v e s ” ) ;
i f ( e3 == e4 )
c o u t << ” e3 == e4 ” << e n d l ;
else
c o u t << ”NOT e3 == e4 ” << e n d l ;
i f ( e1 != e2 )
c o u t << ” e1 != e2 ” << e n d l ;
else
c o u t << ”NOT e1 != e2 ” << e n d l ;
e1 . s e t E n t r y ( ”Maryam ” ) ;
c o u t << e1 . getName ( ) << e n d l ;
}

This should print the following.


NOT e3 == e4
e1 != e2
Maryam

2
2. This exercise is on the topic of inheritance. Using the base class Entry in Question, define a derived class
EntryPlus that inherits all the fields and the member functions of Entry. In addition, EntryPlus contains
the following fields: int streetNumber, string streetName, string city, string province, and string
postalCode. EntryPlus also contains an additional member function, called Print(), which displays the
fields of an EntryPlus object in the following manner/order.
Person name :
S t r e e t number :
S t r e e t name :
City :
Province :
P o s t a l code :
Telephone :

Devise some exhaustive test cases and test that your program is correct. Please submit your test cases (main
file) as well.

You might also like