Assignment 3: CS 115 001 - Object-Oriented Design Due: March 23, 2024
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.
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 ) ;
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 ) ;
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 ;
}
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.