You are on page 1of 3

Concordia University

COMP 249 Summer 2014


Object-Oriented Programming II
Assignment #2


Goal: The goal of the second assignment is to introduce to the concepts of encapsulation, inheritance
abstract classes, interfaces, and polymorphism, as well as apply effectively object-oriented design
principles. You will also have the opportunity to learn how to use external libraries in your project.

Context: Your initial design for the Contact Manager application was very successful and received
positive feedback from the software quality assurance team. However, the requirements team interviewed
some users of contact manager applications and realized that there is a great demand for some additional
features which are not supported by competitive products. As a result, you will have to extend your
original design to support the new requirements. You must be aware that your changes should not affect
the public interface (i.e., method signatures) of already existing classes, since the teams responsible for
the implementation of the desktop application, mobile application and web application component have
already started working based on your initial design. Any changes in your original code will cause
changes to their code as well.

Requirements:
The requirements team has given the following new requirements for the Contact Manager application:

The application should support two different types of contacts, namely business contacts and personal
contacts. Both types have exactly the same properties (i.e., attributes) with the Contact class in the
original design, but additionally they provide some new properties. The business contact allows the
storage of meetings (objects of Meeting class), while the personal contact allows the storage of some
special events (objects of SpecialEvent class), such as birthdays and anniversaries.

Each Meeting has the following attributes:
- start time (DateTime)
- end time (DateTime)
- location (String)
- description (String)
Note: You will have to use the J oda date and time API for creating and using DateTime objects. The
library can be downloaded from http://www.joda.org/joda-time/ and a quick start guide can be found here.
Two meetings are considered equal if their start time, end time and location attributes are equal.

Each SpecialEvent has the following attributes:
- event type [Birthday, Anniversary, Other] (Hint: use Enum types)
- date (DateTime)
- recurring (boolean)
Note: The attribute recurring is used to specify whether the event is recurring every year. Two special
events are equal if their event type and date attributes are equal.

The class BusinessContact will be used to store the meetings corresponding to a contact in an array of
Meeting objects. The class PersonalContact will be used to store the special events corresponding to a
contact in an array of SpecialEvent objects.

COMP 249 / Summer 2014 Assignment #2 page 1

Both Meeting and SpecialEvent classes implement the interface Event which defines the method
isWithinPeriod(DateTime start, DateTime end). This method takes a start date and an end date as
arguments and returns a boolean value which is true only if the event takes place between the start and
end dates.

Task #1

Design and implement the required classes (BusinessContact, PersonalContact, Meeting, SpecialEvent
and Event). Make sure that you create the appropriate inheritance relationships between the classes.
- For each class, create an appropriate constructor that initializes the values of the attributes. (Hint:
attributes of array type should be initialized as empty arrays allowing to store 100 objects at maximum)
- Create method addMeeting() for the addition of a meeting in class BusinessContact. The method
should examine if the meeting passed as argument already exists in the array and add it only if it is not
already present. (Hint: the check should be performed using the corresponding equals() method)
- Create method addSpecialEvent() for the addition of a special event in class PersonalContact. The
method should examine if the event passed as argument already exists in the array and add it only if it is
not already present. (Hint: the check should be performed using the corresponding equals() method)
- Implement method isWithinPeriod() in class Meeting. The method should return true if either the start
time or end time of the meeting is within the specified period. (Hint: use methods isBefore() and isAfter()
of DateTime class to compare the dates)
- Implement method isWithinPeriod() in class SpecialEvent. The value of attribute recurring should be
taken into account. (Hint: use methods isBefore() and isAfter() of DateTime class to compare the dates)
- Modify the main() method in Driver class appropriately and add some meetings and special events to
the contacts.

Task #2

Create method printEventsWithinPeriod() in ContactManager that takes a start date and an end date as
arguments, iterates through the contacts stored in ContactManager and prints the meetings (if the contact
is a business contact) and special events (if the contact is a personal contact) that are within the specified
period. This method should make use of polymorphism by calling method getEventsWithinPeriod()
defined in the Contact inheritance hierarchy. The latter method takes a start date and an end date as
arguments, iterates through the events (meetings or special events) of each contact and returns an array of
the events that take place within the specified period. If the returned array is not empty the method
printEventsWithinPeriod() prints first the name of the corresponding contact and then the returned
events. (Hint: you can check if the returned array is empty by examining if the object in the first position
of the array is null. To print the event use a while loop that checks whether the current element in the
array is not null)











COMP 249 / Summer 2014 Assignment #2 page 2

Submitting Assignment #2

- Zip the Eclipse project directory. External libraries (jar files) should be included in the project.
- Make sure that your source code is compliant with J ava 1.7 (Right-click on your project and select
Properties, Click on Java Compiler in the menu and make sure that the Compiler compliance level is
equal to 1.7)
- If you submit multiple times, only the LAST version will be graded and all others will be disregarded.
- Submit the zip file on Moodle under Assignment 2 link.


Evaluation Criteria for Assignment #2 (10 points)

Task #1 6 points
Class, constructor, accessor method creation 1 point
Implementation of addMeeting() & addSpecialEvent() 1 point
Implementation of isWithinPeriod() methods 1.5 points
equals(), toString() implementation 1.5 points
Proper use of the J oda time external library 1 point
Task #2 4 points
Implementation of printEventsWithinPeriod() 1 point
Proper use of polymorphism 1 point
Implementation of getEventsWithinPeriod() methods 2 points



The requirement Design and implement classes BusinessContact and PersonalContact from the
second assignment will be used to evaluate the graduate attributes Analysis, and Design:
The class BusinessContact will be used to store the meetings corresponding to a contact in an array of
Meeting objects. The class PersonalContact will be used to store the special events corresponding to a
contact in an array of SpecialEvent objects.



Evaluation Criteria for Graduate Attribute Assessment

Relation of attribute to the task Attribute 100%
Choose the appropriate level of abstraction for your
classes.
GA2:
Analysis
20%
Reuse common attributes and avoid duplication GA3:
Design
40%
Reuse common methods and avoid duplication GA3:
Design
40%

COMP 249 / Summer 2014 Assignment #2 page 3

You might also like