UNIVERSITY OF SOUTHERN QUEENSLAND
CSC1401 - Foundation Programming (Semester 2, 2019)
Assignment 3 Specification
Schedule
Due date: 17 October 2019
Weight: 20%
Type: Team-based (3 members)
Goals and Topics
The assignment problem is straightforward. All necessary details have been supplied. The
solution of the problem will use the programming concepts and strategies covered in workshops
1-11 delivered in the course. The subgoals are:
ï‚· Obtaining advanced understanding of values, variables and a
ays;
ï‚· Understanding program input and output, functions and expressions;
ï‚· Understanding simple strategies like iteration, validation, sum, count, minimum,
and maxi-mum plans;
ï‚· Understanding of advanced strategies like swapping, cycle position plan, sorting,
and searching;
ï‚· Understanding of HTML objects, forms, and events;
ï‚· Translating simple design into JavaScript code;
ï‚· The mechanics of editing, interpreting, building and running a program;
ï‚· Testing a program;
ï‚· Commenting source code, especially JavaDoc on functions;
ï‚· Becoming confident and comfortable with programming in problems with other
team members.
The Task
In this assignment you are required to design, implement and test a program that can be used
to manage a simple schedule with appointment records, which are stored in an a
ay. Your
program must provide an interactive editing environment that allows the user to:
ï‚· create new appointment records and add them to the schedule;
ï‚· display all appointment records with details;
ï‚· sort all appointment records based on an attribute;
ï‚· search for specific appointment records in all records based on an attribute.
The program is to be implemented by JavaScript and as an .html file running on Firefox, an OS
independent web
owser.
Schedule
Figure 1 illustrates the schedule with interactive editing environment. Please use this
illustration as the reference for the following descriptions.
Figure 1: The Interactive Editing Environment of schedule
Appointment records
An appointment record this program will hold or encapsulate data for the priority, date, start
time, end time, and subject of the appointment. In respect to each of the attributes, an
appointment record can be represented like the following sample:
"High; 25/09/2019; 13; 15; CSC1401 class"
Which can be deciphered as the appointment with "High" priority, on the date of "25/09/2019",
starting at "1300pm" and finishing at "1500pm", about the subject of "CSC1401 class". You
should create a global variable "an a
ay" to store all such appointments. For the sake of easy
explanation, we refer to this variable by appointmentA
in the rest of this document.
There are some limitations that must be imposed on the appointment records:
1. The primary unit of time in an appointment is hour.
2. An appointment starts and finishes on the same day;
3. Only appointments occu
ing at future time can be added to the schedule;
4. No concu
ent appointments are to be added into the schedule.
Date
A date is valid if and only if:
ï‚· yea
1583 (the beginning of the Gregorian calendar)
ï‚· 1 <= month <= 12
ï‚· 1 <= day <= daysInMonth(month, year)
ï‚· daysInMonth = 30 if the month is April, June, September, or November
ï‚· daysInMonth = 31 if the month is January, March, May, July, August, October, or
December
ï‚· daysInMonth = 28 if the month is Fe
uary and is not a leapYear(year)
ï‚· daysInMonth = 29 if the month is Fe
uary and is a leap Year(year)
A year is a leap year if
ï‚· year is divisible by 400
ï‚· year is divisible by 4 and if year is not divisible by 100
So, the year 2000 was a leap year, 2004 was a leap year but 2100 will not be a leap year.
Time
The time (Start time and End time) of an appointment is valid if and only if:
ï‚· 08:00am <= Start/End Time <= 18:00pm;
ï‚· Start
ï‚· ignore minutes and seconds, only integral point input.
Taking both date and time into account, an appointment needs to start later than the time when
the appointment is being added to the schedule.
Your Tasks
It is strongly suggested that the following approach is to be taken to design and implement the
program.
Interactive Editing Environment (IDE)
You should first design, implement and test the Interactive Editing Environment (IDE) of the
schedule. Refe
ing to Fig. 1 for the details that you need to create in the IDE. You should
adopt on HTML objects and forms (Workshop 11) to design and implement the IDE.
You are welcome to have your own design of the IDE, so as it provides the same features and
information as the sample IDE illustrated in Fig. 1 and is implemented by HTML objects and
forms.
The showRecords() Function
You should design, implement and test a function to show all existing records in the schedule
after the task of IDE is completed. The function should access to the appointmentA
a
ay and
print all existing appointment records in the table form to the IDE. The table will be refreshed
time to time when the function is called, for example, after a new appointment record is added.
You could create some dummy appointment records manually and store them in the
appointmentA
a
ay to test this function, while other functions still remain incomplete.
The addRecord() Function
You should design, implement and test a function to add an appointment record to the schedule.
An appointment record will be added to the schedule each time when the "Add Appointment
ecord" button is pressed, if the appointment record data are all valid. The function handles the
following tasks:
ï‚· Collect all data (Priority, Date, Start Time, End Time and Subject) for the appointment
ecord;
ï‚· Validate if the input for "Date" is co
ect regarding the specification in the Date section
(by using the function isValidDate() described below);
ï‚· Validate if the input for "Time" are co
ect regarding the specification in the Time
section (by using the function isValidTime() described below);
ï‚· Add the appointment record into the appointmentA
a
ay if all data are valid;
ï‚· Call showRecords() to reflect the newly added appointment record on IDE.
The isValidDate() Function
You should design, implement and test a function to validate the data input for the Date
attribute of an appointment record. The function should alert an e
or message and return false
if the input is invalid, otherwise, return true.
Refer to the Date section for what the function needs to check for validation.
The isValidTime() Function
You should design, implement and test a function to validate the data input for the Date, Start
Time and End Time of an appointment. The function should alert an e
or message and return
false if any input is invalid, otherwise, return true.
Refer to the Time section for what needs to be checked for validation.
The isConcu
entAppointment() Function
You should design, implement and test a function to validate if the input data for the Date, Start
Time and End Time of an appointment makes it concu
ent to any existing appointments in
appointmentA
. The time of two appointments are considered concu
ent if one starts or
finishes at a time when the other is still ongoing. Note that an appointment can start at a time
when another finishes, or vice versa.
The function should alert an e
or message and return true if the input appointment is
concu
ent with any existing appointments in appointmentA
, otherwise, return false.
The sortRecords() Function
You should design, implement and test a function to allow the user to sort all appointment
ecords in appointmentA
based on one of the following attributes; Priority, Date, Start/end
time, subject and display the sorted appointment records of schedule when an attribute is
selected in the dropdown list associated with by "by" and the "Sort Appointment records"
utton is pressed. The sorting orders are specified as follows:
ï‚· Priority: "High" to "Low";
ï‚· Date: from earlier date to later date;
ï‚· Start time: following the order of time value of hours, ignore the date value.
ï‚· End time: following the order of time value of hours, ignore the date value.
ï‚· Subject: following the order of co
esponding unicode values, e.g., from A to Z then a
to z ;
You should use string handling techniques to extract the co
esponding attribute values from
the appointment records and sort the appointment records on the basis of these values. When
sorting records based on Date, you should firstly restore the Date object of appointment records
using the extracted Date and Stat Time values and then compare their time value (accessed via
getTime()) for sorting.
The bu
le sort algorithm introduced in Workshop 10 should be employed for the design of
the function.
The searchRecord() Function
You should design, implement and test a function to search the appointment records using the
keywords given by the user. The search process should base on one of the following attributes:
Priority, Date, Start/End time and subject. The program should displays the relevant searching
esults of schedule when an attribute is selected in the dropdown list associated with by "by"
and the "search" button is pressed.
ï‚· The keywords for searchRecord() Function are case insensitive. That means no matter
the users search "Class" or "class", the program will show all the records relevant to
"class" based on selected attribute.
ï‚· By selecting attribute "Subject", once the users search "a", any record whose "subject"
include the character "a" will be displayed. For example, both "birthday" and "class"
include character "a", so their relevant records will be displayed. Do the same design
for attribute "Priority".
ï‚· By selecting attribute "Date", once the users search "1", any record whose "Date"
include the number "1" will be displayed. No matter the number "1" is for day, month
or year. However, the records only include "25/09/2019" won’t be displayed, because
"2019" is number "2019". In this situation, we treat search keyword number "1" is not
included in "2019" as a single character. The same treatment is for attributes "Start/End
Time" too. When you search "7" based on attribute "Start Time", the "7" related records
will be displayed, but "17" related records won’t be displayed.
You don't have to list the search results following any specific order. The search plans
discussed in Workshop 10 should be employed in the design of the function.
Program Integration Test