Welcome to Assignment 2 for COMP90041 – Programming and Software Development!
In this assignment, we will extend the Calendar Console to add new features
like –
The slides from this lesson module for the assignment act as “the specifications” for the system we are about to build.
“The specifications” in real-life software development is the document that details the features that should be implemented in any particular project. They are the features and requirements that you, the Software Developer, and the client have agreed should be implemented in the system.
As such, you should read these specifications carefully and ensure that your program implements the requirements of the specification correctly.
Tests will be run on your program to check that you have implemented these specifications correctly. Note that for the Assignment 2, we will provide 10 visible tests and 6 hidden tests that you can run to check that the basic functionality of your system is correct.
Tip: Look at the assets file present. Think about what can the hidden test cases be about by looking at the data and perform your own testing.
So once your program passes the basic tests, we strongly recommend that you perform further tests yourself, to ensure that the required features have been implemented correctly.
How to read the specifications?
inputs.
Best Case Scenario: This section describes a real-life intended scenario.
This will be notified using a green strip as shown below –
Carried Forward: This section is referred as is from Assignment 1
be tested and are shown below –
Worst Case Scenario: Your program may behave incorrectly if not handled explicitly.
modifications. This will be notified using a yellow strip.
Modifications: This section is referred from Assignment 1 with slight modifications
like below-
Addition: This specification is entirely new to Assignment 2.
embedded as a red strip in the specifications.
Out of Scope Scenario: This scenario …….. is out of scope for this assignment
callouts.
represent the inputs to the program.
Students can assume that test cases only contain outputs that are explicitly part of specifications. The test cases do not produce any output that is not mentioned in the specifications explicitly. Please note that the specifications will give you warnings and important notes where we expect special input handling. You should observe those and implement them accordingly as they will be tested while marking your program.
The Intended Learning Outcomes for the final Project are mentioned below –
cases in specifications.
use java.nio.Files methods.
applies to incorrect usage.
penalty or extra marks for using Generics.
A warning to those who have previous programming experience in other programming languages (like C or Python) that follow a procedural programming paradigm: Be careful to develop your program using object-oriented principles, as programming and structuring your code in a way that is not object-oriented is an easy way to lose marks for structure in the assignments.
We will also be assessing your code for good structure and style.
Use methods when appropriate to simplify your code, and avoid duplicate code.
Use correct Java naming conventions for class names, variable names, and method names and put them in a well-organised way in your code i.e. it should be readable as well. Look at the conventions provided by Oracle here.
The code structure in a file is very important and improves readability.
Look at the code organisation conventions provided by Oracle here. Make sure the names you choose are meaningful to improve the readability of your code.
Ensure to add meaningful comments in between your code and Javadoc comments for classes and methods.
We will provide a marking scheme to help guide you in the development of your program. Also we will guide you how to model your program. But using correct syntaxes and conventions can be learnt here.
Calendar Console have changed. Here is some information about the data Calendar Console can process.
A calendar can have multiple calendar entries. Each calendar entry has a calendar date and can have zero or more events. A calendar is initialised with
a start date. The calendar can be viewed in three modes –
weeks.
Each event in a calendar entry has a description. Events can either be
Timed Events also have start and end times in the format HH: mm.
days.
Assumption: Though Sat/Sun are non-working days but are not tested in this Assignment
A timed event on a non-working day has a special criterion. If someone tries to set up a meeting that conflicts with an existing scheduled meeting or a meeting is set up on a non-working day, the program will send an email to reschedule the event.
Pro Tip: Sending an email here simply uses print statements. No overly complicated coding required for the assignment.
Your program will have three command-line inputs. These are – • Date in the format yyyy-MM-dd to initialise the calendar’s start date
be MONTHLY, FORTNIGHTLY, or WEEKLY.
$java CalCon 2025-05-26 MONTHLY assets/events1.txt
Error Scenarios
Worst Case Scenario: Your program may behave incorrectly if the params are not handled explicitly. These inputs will be tested with varied data. The data files name may change but will always be String.
The program can face below error scenarios and must handle them by
printing the error messages accordingly and terminating the program.
Exiting Program.
Print Invalid Date. Exiting Program.
Program.
If valid command line arguments are present, initialise the calendar.
Once the calendar is initialised, it is important to read some data from the files and load them into the appropriate objects of classes. The files are present in assets folder.
Assumption: While handling the files in code, you can assume the folder name assets remain unchanged.
File Data Description
The file has data in a comma-separated format. Where data is missing, the comma will still be present. The file has a header that describes the data
present in it. The order of the data will always remain the same.
be considered Invalid.
considered Invalid.
represents the start time of the event. Otherwise empty.
represents the end time of the event. Otherwise empty.
Note that the file names may change. The folder names won’t change. You must not hardcode the file names in the code.
command line arguments.
must ignore this while reading the data.
the data by comma and processing individual data points.
invalid data or an invalid line format. In this case, skip the line and proceed to read the next line. The program must not be terminated.
See the next section for Exception handling.
Note: Remember in java the file extensions doesn’t matter as long as the content is text in nature. So you may or may not have any file extensions like .txt
The program must write the changes made to the events during the program execution back to the events file using the filename provided to the program in the command line argument. The data is read from the calendar. For those dates where one or more events are present, the program will write the data back to the file. The order of the events is maintained by the order of insertion in the events array.
While writing the data back, the header must be reserved as is. The program must update the events file only once at the end of the program when the user has quit from the main menu (See Option 4 in Main Menu slides)
Several exceptions may happen in the program.
Worst Case Scenario: Your program may behave incorrectly if not handled explicitly. These kind of inputs will be tested.
Unable to process file. Exiting program.
Invalid Event Line. Skipping this line.
to the next line.
Note that if one line has more than one error, only first error encountered is printed and the program moves on to the next line.
The order of processing the datapoints and respective errors is as follows –
Skipping this line.
event type. Skipping this line. or Invalid Timed event type. Skipping this line.
empty. Skipping this line. or End Time cannot be empty. Skipping this line.
Incorrect Start Time format. Skipping this line. or Incorrect End Time format. Skipping this line.
Assumption: Since we are reading a comma separated file, none of the string data like description will have a comma as a data. Comma is only used to represent data delimiter and not data itself.
If the date in the events file is correct but is outside the calendar view, print
Date is outside calendar view. Skipping this line.
Worst Case Scenario: Remember that the method that throws the exception does not catch and handle it. See the marking scheme.
There are no exceptions thrown during Program Execution, but they are handled using logic. See the next few slides on program execution for details.
Modifications: This section is referred from Assignment 1 with slight modifications.
Once the calendar is initialised, the program will show the Calendar initialised with dates and the cursor ‘x’ on the first date. Remember, the calendar view will differ based on the calendar view type. The MONTHLY view is the same as Assignment 1. Here are the other views shown –
FORTNIGHTLY
———————————— | M | T | W | T | F | S | S |
————————————
| 02 | 03 | 04 | 05 | 06 | 07 | 08 |
| x | | | | | | |
| | | | | 2 | | |
————————————
| 09 | 10 | 11 | 12 | 13 | 14 | 15 |
| | | | | | | |
| | | | | | | |
———————————— WEEKLY
———————————— | M | T | W | T | F | S | S |
————————————
| 02 | 03 | 04 | 05 | 06 | 07 | 08 |
| | | | | x | | |
| 2 | | 1 | | 2 | | |
————————————
The next thing to show is the main menu for the user to select and perform some operations.
Modifications: This section is referred from Assignment 1 with slight modifications.
———————————— | M | T | W | T | F | S | S |
————————————
| 02 | 03 | 04 | 05 | 06 | 07 | 08 |
| x | | | | | | |
| 2 | | 1 | | 2 | | |
————————————
Select an option to proceed.
Press 1 to select a date.
Press 2 to enter current selection’s sub menu.
Press 3 to view all events in a calendar.
Press 4 to exit.
>
To add/edit/delete the event(s) in the calendar, the user must select a date first. The first date is selected by default. To select any other date, the user
simply inputs a date when prompted.
Note, the date can be in an invalid format or outside the calendar view. In such cases, the program must print an error message and ask the user to input the date again. See sample output below –
———————————— | M | T | W | T | F | S | S |
————————————
| 26 | 27 | 28 | 29 | 30 | 31 | 01 |
| x | | | | | | |
| | | 2 | 1 | 1 | | |
————————————
Select an option to proceed.
Press 1 to select a date.
Press 2 to enter current selection’s sub menu.
Press 3 to view all events in a calendar.
Press 4 to exit.
> 1
Enter a date in yyyy-MM-dd format : 2025-06-02
Date is outside calendar view.
Enter a date in yyyy-MM-dd format : 2025-06 Incorrect date format.
Enter a date in yyyy-MM-dd format : 202-09-01 Invalid date.
Enter a date in yyyy-MM-dd format : 2025-05-27
Date selected successfully
———————————— | M | T | W | T | F | S | S |
————————————
| 26 | 27 | 28 | 29 | 30 | 31 | 01 |
| | x | | | | | |
| | | 2 | 1 | 1 | | |
————————————
Select an option to proceed.
Press 1 to select a date.
Press 2 to enter current selection’s sub menu.
Press 3 to view all events in a calendar.
Press 4 to exit.
>
Note: The text in bold represents user input here. You don’t need to make the console inputs bold in your code.
Carried Forward: This section is referred as is from Assignment 1
Once the user has selected a date, they can now add/edit/view/delete an event marked on the calendar for the selected date. The program should print a submenu –
———————————— | M | T | W | T | F | S | S |
————————————
| 26 | 27 | 28 | 29 | 30 | 31 | 01 |
| | | x | | | | |
| | | 2 | 1 | 1 | | |
————————————
Select an option to proceed.
Press 1 to select a date.
Press 2 to enter current selection’s sub menu.
Press 3 to view all events in a calendar.
Press 4 to exit.
> 2
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event. Press Q to exit.
Submenu handling is discussed here.
Option 3: Printing all events.
Modifications: This section is referred from Assignment 1 with slight modifications.
If the user wants to see all the events marked in the calendar, the program must present them in a tabular form. The program must show only the events present in the calendar view and not all the events read from the file.
———————————— | M | T | W | T | F | S | S |
————————————
| 26 | 27 | 28 | 29 | 30 | 31 | 01 |
| | | x | | | | |
| | | 2 | 1 | 1 | | |
————————————
Select an option to proceed.
Press 1 to select a date.
Press 2 to enter current selection’s sub menu.
Press 3 to view all events in a calendar.
Press 4 to exit.
> 3
—————————————————————————-
——————————————————————–
ID Date Event Type Event SubType Start Time End Time Description
—————————————————————————-
——————————————————————–
On Vacation – Canada
Some random event
On Vacation – Canada
On Vacation – Canada
—————————————————————————-
——————————————————————–
Tip: Use the formatter %2s%12s%12s%20s%12s%12s%40s%n to print the header and the events.
However, if the calendar has no events, the program should show an error message.
———————————— | M | T | W | T | F | S | S |
————————————
| 26 | 27 | 28 | 29 | 30 | 31 | 01 |
| | | x | | | | |
| | | | | | | |
————————————
Select an option to proceed.
Press 1 to select a date.
Press 2 to enter current selection’s sub menu.
Press 3 to view all events in a calendar.
Press 4 to exit.
> 3
No events present in the calendar.
———————————— | M | T | W | T | F | S | S |
————————————
| 26 | 27 | 28 | 29 | 30 | 31 | 01 |
| | | x | | | | |
| | | | | | | |
————————————
Select an option to proceed.
Press 1 to select a date.
Press 2 to enter current selection’s sub menu.
Press 3 to view all events in a calendar. Press 4 to exit.
Carried Forward: This section is referred as is from Assignment 1
In case the user selects option 4, the program must gracefully quit the program and print a goodbye message.
Look at the complete output below.
———————————— | M | T | W | T | F | S | S |
————————————
| 26 | 27 | 28 | 29 | 30 | 31 | 01 |
| x | | | | | | |
| | | 2 | 1 | 1 | | |
————————————
Select an option to proceed.
Press 1 to select a date.
Press 2 to enter current selection’s sub menu.
Press 3 to view all events in a calendar.
Press 4 to exit.
> 4
Exiting CalCon Now.
Warning: Do not use System.exit() as it is not a graceful exit. Penalty will be applied.
Carried Forward: This section is referred as is from Assignment 1
In case the user provides an invalid input, like 8 or 9, the program should be able to print “Invalid Input” and show the main menu. Sample output
———————————— | M | T | W | T | F | S | S |
————————————
| 26 | 27 | 28 | 29 | 30 | 31 | 01 |
| x | | | | | | |
| | | 2 | 1 | 1 | | |
————————————
Select an option to proceed.
Press 1 to select a date.
Press 2 to enter current selection’s sub menu.
Press 3 to view all events in a calendar.
Press 4 to exit.
> 6
Invalid input.
————————————
| M | T | W | T | F | S | S |
————————————
| 26 | 27 | 28 | 29 | 30 | 31 | 01 |
| x | | | | | | |
| | | 2 | 1 | 1 | | |
————————————
Select an option to proceed.
Press 1 to select a date.
Press 2 to enter current selection’s sub menu.
Press 3 to view all events in a calendar.
Press 4 to exit.
>
Out of Scope: The program only expects an integer value for the main menu. You do not need to handle string or double values as input at this point of time for the main menu.
Once the submenu is printed, the user can take multiple actions.
Modifications: This section is referred from Assignment 1 with slight modifications
To add an event, the program must take certain data inputs from the user. Once taken, it should add the event to that date. Note that there could be more than one event added to a date. Once an event is added and the user returns to the main menu, the calendar should also show the updated count for the number of events present on a date. See the output below –
Adding a Timed Event
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
> A
To add an event, enter the following details
Event Type (ALL_DAY, TIMED) : TIMED
Event SubType (REMINDER, MEETING) : MEETING
Start Time (HHmm) : 10:30
End Time (HHmm) : 11:30
Description : Some random meeting
Event added successfully.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
>
Adding an All Day Event
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
> A
To add an event, enter the following details
Event Type (ALL_DAY, TIMED) : ALL_DAY
Event SubType (BIRTHDAY, ANNIVERSARY, OUT_OF_OFFICE, PUBLIC_HOLIDAY) : OUT_OF_OFFICE
Description : Sick Leave Event added successfully.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
>
Assumption: All inputs are valid. Invalid inputs not tested in add/edit events.
Modifications: This section is referred from Assignment 1 with slight modifications
To edit an event, the user should select the event number to edit from. Thus, we will show all the events on the selected date and let the user choose from the events to edit. See Option V to understand how to show the list of events for Timed vs All-day events. Once the event number is selected, the program should prompt the user to input details similar to the add event scenario. See the output below – Editing a Timed Event
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
> E
To edit an event, select an event number from below –
Following event(s) found for the day –
To edit this event, enter the following details Event Type (ALL_DAY, TIMED) : TIMED
Event SubType (REMINDER, MEETING) : REMINDER
Start Time (HHmm) : 16:00
End Time (HHmm) : 16:15 Description : Call Tax office
Event updated successfully.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
>
Editing an All Day Event
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
> E
To edit an event, select an event number from below –
Following event(s) found for the day –
> 1
To edit this event, enter the following details
Event Type (ALL_DAY, TIMED) : ALL_DAY
Event SubType (BIRTHDAY, ANNIVERSARY, OUT_OF_OFFICE, PUBLIC_HOLIDAY) : OUT_OF_OFFICE
Description : Sick Leave updated
Event updated successfully.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
>
Carried Forward: This section is referred as is from Assignment 1
Deleting an event is similar to editing an event. The user must choose the event number from the list of events present on the day to delete. See the output below –
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
> D
To delete an event, select an event number from below –
Following event(s) found for the day –
> 2
Event deleted successfully.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
>
If the user selects option V after this, the deleted event should not be present
in the list.
Modifications: This section is referred from Assignment 1 with slight modifications
Viewing a day’s events will simply list all the events present on the selected
day, but in a concise manner.
the description.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
> V
Following event(s) found for the day – 1. OUT_OF_OFFICE Event : On Vacation – Canada
Tip: Use the formatter “%d. %s Event : %s – %s : %s%n” to print a Timed event for the day and “%d. %s Event : %s%n” to print a All Day event.
Carried Forward: This section is referred as is from Assignment 1
If the user selects Q, the program must quit the submenu, print the calendar view and go back to the main menu.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
> Q
———————————— | M | T | W | T | F | S | S |
————————————
| 02 | 03 | 04 | 05 | 06 | 07 | 08 |
| x | | | | | | |
| 2 | | 1 | | 2 | | |
————————————
Select an option to proceed.
Press 1 to select a date.
Press 2 to enter current selection’s sub menu.
Press 3 to view all events in a calendar.
Press 4 to exit.
>
Carried Forward: This section is referred as is from Assignment 1
Note that the submenu receives an input string for A/E/D/V/Q. Thus, any input which is a string but is not a valid option should be handled accordingly, with an error message printed.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
> K
Invalid input.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
>
Case 1: No events present for the day.
Carried Forward: This section is referred as is from Assignment 1
In case of editing/deleting/viewing, if there are no events present for the day, show the error message and print the submenu.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
> V
There are no events marked in the calendar for the day.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
>
Addition: This specification is entirely new to Assignment 2.
While adding or editing a meeting event, if the calendar date is marked with Out of Office or Public Holiday, the program should allow adding a meeting, but it should create a method sendEmail() that prints a warning I am not available today. Please reschedule the event.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
> A
To add an event, enter the following details Event Type (ALL_DAY, TIMED) : TIMED
Event SubType (REMINDER, MEETING) : MEETING
Start Time (HHmm) : 10:30
End Time (HHmm) : 11:30
Description : Some random meeting
Event added successfully.
I am not available today. Please reschedule the event.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
>
Assumption: Adding other kind of events to a Non Working day is not tested.
Addition: This specification is entirely new to Assignment 2.
While adding/editing the meeting has a time overlap with other meetings i.e.
before the end time of the other meeting
but before the end time of the other meeting
meeting, but has an end time after the start time of the other meeting. In this case, the program should send an email(create a method sendEmail() that prints the error message There is a conflict for this event, Reschedule the event.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
> V
Following event(s) found for the day – 1. REMINDER Event : 14:00 – 14:15 : Take medicine 2. MEETING Event : 10:30 – 11:30 : Team sync-up
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
> A
To add an event, enter the following details Event Type (ALL_DAY, TIMED) : TIMED
Event SubType (REMINDER, MEETING) : REMINDER
Start Time (HHmm) : 10:45
End Time (HHmm) : 11:00 Description : Call mom.
Event added successfully.
There is a conflict for this event, Reschedule the event.
Press V to view all events.
Press A to add an event.
Press E to edit an event.
Press D to delete an event.
Press Q to exit.
>
create other classes as well.
classes. Create the data fields as instance variables in those classes.
of time.
you are using the Integer.parseInt.
exceptions as well.
at least one inheritance hierarchy.
and implement at least one interface.
reading and writing.
this method to perform a split on comma.
Your code should be annotated using javadoc comments. We will generate the javadoc for your code. You do not need to submit it. You can run javadoc on your machine (up to any levels of nested packages) by running the
command
$ javadoc -d docs/ **/*.java
The UML Diagram is discussed in the Week 9 Lecture in detail. The UML Diagram present in the code challenge is just a starter code, which can act as a scaffold or guide you what are mandatory classes/methods in the
assignment.
You must create packages and add the classes to some packages.
methods present there.
<<abstract>>, and the italicised method is an abstract method. You are
free to change the definition of the abstract method by adding parameters if you see that is fit, but the Event class must be
abstract.
Reviews
There are no reviews yet.