UNIVERSITY OF SOUTHERN QUEENSLAND
CSC1401 - Foundation Programming (Semester 1, 2019)
Assignment 3 Specification
The HomewareCity Shopping Cart System
Due date: 30 May 2019
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 arrays;
• 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 and shuffling, cycle position plan, sorting, tallying, and searching;
• Understanding of HTML objects, forms, and events;
• 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 small problems.
In this assignment you are required to design, implement and test a program that can be used to manage a simple shopping cart system with shopping records, which are stored in an array. Your program must provide an interactive editing environment that allows the user to:
• create new shopping records and add them to the shopping cart system;
• display all shopping records with details;
• tally all shopping records for summary of the shopping; • sort all shopping records based on an attribute;
• search for specific shopping records in all records.
Shopping cart system
Figure 1 illustrates the shopping cart system with interactive editing environment. Please use this illustration as the reference for the following descriptions.
Figure 1: The Interactive Editing Environment of shopping cart system
A shopping record this program will hold or encapsulate data for the condition, date, time, cost, and items of the shopping information. In respect to each of the attributes, a shopping record can be represented like the following sample:
“New; 25/05/2019; 14; 450; Sofa, sofa cover-
Which can be deciphered as the shopping record with -New- condition, on the date of -25/05/2019-, shopping at 14:00pm (ignore minutes and seconds), items are -Sofa, sofa cover-, You should create a global variable - array - to store all such shopping records. For the sake of easy explanation, we refer to this variable by shoppingRecordArr in the rest of this document.
There are some limitations that must be imposed on the shopping records: Date
A date is valid if and only if:
• year 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 February and is not a leapYear(year)
• daysInMonth = 29 if the month is February 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 of a shopping record is valid if and only if: • 08:00am = Time = 18:00pm;
• ignore minutes and seconds, only integral point input.
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 shopping cart system. Referring 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 shopping cart system after the task of IDE is completed. The function should access to the shoppingRecordArr array and print all existing shopping 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 shopping record is added.
You could create some dummy shopping records manually and store them in the shoppingRecordArr array to test this function, while other functions still remain incomplete.
The addRecord() Function
You should design, implement and test a function to add a shopping record to the shopping cart system. A shopping record will be added to the shopping cart system each time when the -Add Shopping record- button is pressed, if the shopping record data are all valid. The function handles the following tasks:
• Collect all data (Condition, Date, Time, Cost and items) for the shopping record;
• Validate if the input for -Date- is correct regarding the specification in the Date section (by using the function isValidDate() described below);
• Validate if the input for -Time- are correct regarding the specification in the Time section (by using the function isValidTime() described below);
• Add the shopping record into the shoppingRecordArr array if all data are valid; • Call showRecords() to reflect the newly added shopping record on IDE.
The isValidDate() Function
You should design, implement and test a function to validate the data input for the Date attribute of a shopping record. The function should alert an error 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 Time of a shopping record. The function should alert an error 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 sortRecords() Function
You should design, implement and test a function to allow the user to sort all shopping records in shoppingRecordArr based on one of the following attributes; Condition, Date, Time, Cost and items and display the sorted shopping records of shopping cart system when an attribute is selected in the dropdown list associated with by -by- and the -Sort Shopping records- button is pressed. The sorting orders are specified as follows:
• Condition: -New- to -Used-;
• Date: from earlier date to later date;
• Time: from earlier time to later time (following the order of time value of hours, ignore the date value);
• Cost: from high to low;
• Items: following the order of corresponding unicode values, e.g., from A to Z then a to z ;
You should use string handling techniques to extract the corresponding attribute values from the shopping records and sort the shopping records on the basis of these values. When sorting records based on Date, you should firstly restore the Date object of shopping records using the extracted Date and Time values and then compare their time value (accessed via getTime()) for sorting.
The bubble sort algorithm introduced in Workshop 10 should be employed for the design of the function.
The tallyRecords() Function
You should design, implement and test a function to calculate the number of shopping records each day by using the tally plan and display the information of shopping cart system as a summary when the -Summary- button is pressed. Note that only the days occurred with shopping records will display. The tallying plan and searching for min/max plan discussed in Workshop 10 should be employed in the design of the function.
You should use the followings as the guideline:
• Find the earliest day and the latest day with shopping records by using the min and max plan.
• You should first restore the Date object of shopping records using the Date value extracted from shopping records using string handling techniques and then compare their time value (accessed via getTime()) to find the earliest day (the min plan) and the latest day (the max plan).
• Following the tally plan, create an array and make it ready for tallying. The length of array should be the number of days sitting between the earliest day and the latest day. For example,if the earliest day is 23/05/2019 and the latest day is 29/05/2019, the tally array should be with a length of 7.
• Access to each of the shopping records in shoppingRecordArr and restore its Date object as discussed above. Calculate the number of days counting from the shopping record day to the earliest day and use it for the index of the element in the tally array that you will increment the value.
• Calculate the total cost for all the records in the same day and show it in the summary table.
• To display the tally result as the summary of the shopping cart system, access to each of the elements in the tally array and restore the Date object if the value is greater than 0. The Date object can be restored by using the time value in milliseconds, which is calculated by the number of milliseconds per day multiplying the number of days in difference to the earliest day (the index) and then adding it to the time value of the earliest day. You can then access to the value of day, month, and year by using getDate(), getMonth(), and getFullYear().
The searchRecord() Function
You should design, implement and test a function to search the shopping records using the keywords given by the user and display the searching results of shopping cart system when the -Search- button is pressed. You dont 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
You need to test the program for all functionality thoroughly before delivering the program to client. The program should be running appropriately without any syntax or logic errors.
What You Need to Submit - Two Files.
For a complete submission you need to submit two files as specified below. The assignment submission system will accept only the files with extensions specified in this section.
1. Statement of Completeness in a file saved in .doc, .docx, .odt, .rtf or.pdf format in 300-400 of your own words describes the following issues. You should first specify the registered name of the team and all members name and student ID on the top of the statement.
• The state of your assignment, such as, any known functionality that has not been implemented, etc. (It is expected that most teams will implement all of the functionality of this assignment).
• Meeting attendance and code contribution summary see Statement of Completeness (team-based) document
• Problems encountered, such as, any problems that you encountered during the assignment work and how you dealt with them. This may include technical problems in programming and people-soft problems in team working;
• Reflection, such as, any lessons learnt in doing the assignment and handling team working and suggestions to future programming projects.
1. The program in a file saved with an .html extension contains the source code implemented following the functional and non-functional requirements.
Plan to complete the assignment on time. Do not write all of the code in one sitting and expect that everything will be working smoothly like a magic.
First step Form and register a team or check again the registration status of your team if you have registered it. Read assignment specification carefully. Clarify anything unclear by putting a post on the Assignment 3 Public Forum. Have your team meeting regularly (face-to-face or on private forum) for discussions on assignment requirements and team working style. Have a discussion on the options of either meeting more challenges to design the program by yourself or simply implementing the game based on the design provided, make a design and then stick with it. Think about how to do it, how to test it, devise high-level algorithms for each independent part of the assignment. Begin to type program (with comments), in incremental stages, and help each other in team.
Second step Keep working on team basis and have your team meeting regularly. Re-read the specification, continue to refine design of various sections to code, bring up any problems to team for advice or to the public forum if necessary. By the end of the term you should have had a working program and some integration tests done.
Third step Fully test the program; have another review on the source code; re-read the specification (especially marking criteria) to make sure you have done exactly what is required. Have a team meeting to discuss the experience. Write the Statement of Completeness- and make the final submission.
Plagiarism and Academic Misconduct
USQ has zero tolerance to academic misconduct including plagiarism and collusion. Plagiarism refers to the activities of presenting someone elses work as if you wrote it yourself. Collusion is a specific type of cheating that occurs when two or more students exceed a permitted level of collaboration on a piece of assessment. Identical layout, identical mistakes, identical argument and identical presentation in students assignments are evidence of plagiarism and collusion. Such academic misconduct may lead to serious consequences, such as:
• Required to undertake additional assessment in the course
• Failed in the piece of assessment
• Awarded a grade of Fail for the course
• Withdrawn from the course with academic penalty
• Excluded from the course or the program for a period of time Refer to USQ Policy Academic Misconduct- for further details.
Late Submission and Extension Request
Please refer to USQ Policy Library - Assessment Procedure for information on the late submission policy and USQ Policy Library - Assessment of Compassionate and Compelling Circumstances Procedure for considerable special circumstances in extension request.
The Extension Request Form is available on the courses StudyDesk. Should you need to request an extension please fill the form and email it to the Course Examiner with supportive documents (e.g., medical certificate or endorsement letter from supervisor in workplace) prior to the due date. Please note that any requests without supportive documents will be rejected directly.
You should use Table 1 as the checklist for implementation and to guide the testing of your program. The total 40 marks will then be converted to 20, which is the grade carried by Assignment III.
Table 1: Marking Criteria
ID REQUIREMENTS Mark
Statement of Completeness (7 marks)
1 The statement is in appropriate length of 300-400 of own words covering issues on both programming and team working. 1
2 The -State of assignment- reflects the true state of completeness. 1
3 The -Meeting attendance and code contribution summary- is presented clearly as required. 3
4 The -Problems encountered- discusses problems and dealing strategies. 1
5 The Reflection- discusses learned lessons and reasonable suggestions 1
Functional Requirements (23 marks)
6 The program IDE is set up as illustrated in Figure 1, The area for adding a new shopping record 2
7 Other areas such as those for sorting, summarising, and searching records 1
8 The showRecords() function displays all records appropriately 1
9 The addRecords() function is designed and implemented appropriately, calls to other functions for validation of the input. 2
10 if valid, adds the record to shopping cart system 1
11 The isValidDate() function is designed and implemented appropriately, validate input for leap years 1
12 validate input for other criteria in Date section 1
13 The isValidTime() function is designed and implemented appropriately 1
14 The sortRecords() function is designed and implemented appropriately employing the bubble sort algorithm, the function sorts records appropriately based on -Date- 2
15 the function sorts Records appropriately based on -Items-, -Condition-,-Cost- and -time- 2
16 The tallyRecords() function is designed and implemented appropriately, finding the earliest day and latest day of records to help create the tally array 2
17 tallying the records appropriately 3
18 displaying tally result (summary) of shopping cart system in appropriate format 1
19 The searchRecord() function is designed and implemented appropriately, the function finds matching records in accordance to the given keywords 2
20 search results display in appropriate format 1
Non-functional Requirements (10 marks)
21 The script is running free from any syntax errors, no code goes outside of script section except from what provided in template 1
22 No functions and strategies used in the script are beyond the course content 1
23 ALL functions should be formally commented in JavaDoc (appropriate in both style and content) 3
24 Code is grouped based on the common tasks attempting to. Each block of code is commented briefly 1
25 Code in the script is organised in order of global variables, global statements, and functions 1
26 All identifiers follow conventions in professional style 1
27 Code in the script is indented correctly for all loop, if-else statements, and functions 1
28 Code has been cleaned, all testing statements (e.g., print-lining) are removed. 1