Application of Programming in Java
Value:20%
Due Date:01-Oct-2018
Return Date:22-Oct-2018
Length:Submission method options:EASTS (online)
Task
back to top
Task 1
Value: 12 marks
For this task you will create a
Subjectclass, whose instances will represent the subjects for study at a university. A subject will have a name, just a
String, and a subject code, which is a six-character
String. The first three characters of a subject code are alphabetic and the last three are numeric. The first three characters define the subject's discipline area. A subject code must be unique.You will also write a
TestSubjectclass to test the use of your
Subjectclass. In particular this will maintain an array of subjects. In order to manage the uniqueness of the subject codes, your program will need to display information about existing subject codes as well as checking that any new subject code supplied by the user is not the same as any existing subject code.The following state and functionality should be provided for the
Subjectclass:
- Two fields will hold the subject’s name and the six-character subject code.
- A constructor will allow a name and a new, validated subject code to be provided when a new subject is created.
- Getters will provide access to the attributes.
- An accessor method calledgetDisciplinewill return a string containing the first three characters of the subject code.
- Another accessor method calledcodeMatcheswill return a boolean value indicating if the subject's code matches the string argument provided. "Matches" is used here in the same sense as for thematchesmethod of theStringclass.
- AtoStringmethod will return a string containing the subject code and subject name.
To assist with managing subject codes and their uniqueness you will provide the
Subjectclass with some class methods as follows:
- AnallDisciplinesmethod will accept an array ofSubjectobjects. It will return an array containing the different 3-character discipline codes represented in the array of subjects in alphabetically order.
- AcodesPerDisciplinemethod will accept an array ofSubjectobjects and a 3-character discipline code. It will return an array containing the different subject codes represented in the array of subjects for the particular discipline.
- AnisValidCodemethod will accept a string that is a possible new subject code, and return a boolean indicating whether it satisfies the structural requirements for a subject code.
- AcodeExistsmethod will accept an array ofSubjectobjects and a possible new subject code. It will return a boolean indicating whether that code has already been allocated to one of the subjects in the array.
- AsortDisciplinesmethod will accept an array ofSubjectsobjects. It will return the sorted array of subjects in alphabetically order.
Your
TestSubjectprogram will perform the following sequence of actions, using good design techniques such as in the appropriate use of methods:
- An initial array ofSubjectobjects will be created from any data in a file that was previously saved by the program. You need to read those data from the file and process other requirements (see below)
- The user interaction will then proceed to allow the user to add one or more new subjects to the array. If the user wishes to add new subjects, the discipline areas of existing subjects should be displayed in alphabeticallyorder. The user will then enter a discipline code to which the program will respond by displaying any existing subject codes in that discipline. This procedure simplifies the user’s task of choosing subject codes that do not already exist, but does not prevent user mistake. Each subject code entered by the user should be checked. The user can enter any new subjects in that discipline (or indeed in other disciplines). The user should be given the choice of repeating the processing for other discipline areas.
- When the user has finished adding subjects, and only if subjects have indeed been added, the program will overwrite the data file with the updated data.
Note:
- You may use anArrayListto implement an array if you prefer and it is appropriate.
You need to submit java and class files, a short discussion to explain the logic on how the problem has been solved, and sample output (for detail please see marking guide and presentation below).
Task 2
Value: 8 marks
Design a class named
Trianglethat extends
GeometricObjectclass (see GeometricObject class in the textbook). The
Triangleclass contains:
- Three double data fields named side1, side2, and side3 with default values 1.0 to denote three sides of the triangle.
- A no-arg constructor that creates a default triangle.
- A constructor that creates a triangle with the specified side1, side2, and side3.
- The accessor methods for all three data fields.
- A method named getArea() that returns the area of this triangle.
- A method named getPerimeter() that returns the perimeter of this triangle.
- A method named toString() that returns a string description for the triangle.
The formula to compute the area of a triangle is:
;
The toString() method should return all side information.
Draw the UML diagram that involves the class Triangle. Implement the class. Write a test program that creates a Triangle object with sides 3.0, 4.0, 5.0, color yellow and filled true, and displays the area, perimeter, color, and whether filled or not.GeometricObjectclass is given below.
You need to submit java and class files, a short discussion to explain the logic on how the problem has been solved, UML diagram, and sample output (for detail please see marking guide and presentation below).
Rationale
back to top
This assessment task will assess the following learning outcome/s:
- be able to interpret design requirements expressed in UML (Unified Modelling Language).
- be able to apply inheritance and aggregation patterns in the design and implementation of programs.
- be able to manipulate simple file operations using Java.
Marking criteria and standards
back to top
Marking guide of the specific tasks:
Assessment 3 (Total marks 20)
|
Task 1 (total marks 12)
|
Criteria
|
Marks
|
Pass
|
CR
|
DI
|
HD
|
a. Execution:Program launches, executes and terminates without crashing; program executes as specified.
|
1.0
|
Provide java file and it executes without crashing towards intended output but a significant number of methods are missing (0.5)
|
Provide java file and it executes without crashing towards intended output but one/two methods are missing (up to 0.75)
|
Provide java file and it executes without crashing towards intended output but one method is missing (up to 0.85)
|
Provide java file and it executes without crashing towards intended output (up to 1.0)
|
b. Program design & implementation:Subject (4), TestSubject (2), and file read/write (2) classes are implemented as specified, showing good logic.
|
8.0
|
Implement and integrate Subject and TestSubject classes with some methods using file read & write (4.0)
|
Implement and integrate Subject and TestSubject classes with majority of the methods using file read & write (4.5-5.5)
|
Implement and integrate Subject and TestSubject classes with all methods using file read & write with minor error (6-7)
|
Implement and integrate Subject and TestSubject classes with all methods using file read & write maintaining logical flow (8)
|
c. Presentation:Code uses good style (indentation, comments)
|
1.0
|
Provide arbitrary variable names, no proper indentation, and very few comments (up to 0.5)
|
Provide a number of variable names but not all by maintaining proper naming convention, occasionally proper indentation, and comments on only important calculation (up to 0.65)
|
Maintain proper naming convention of all variables, proper indentation on each block of codes, and provide comments on only important calculation (up to 0.75)
|
Maintain proper naming convention of all variables, proper indentation on each block/line of code(s), and provide important inline comments (up to 1.0)
|
d. Submission:The documents with all components such as java files, class files and discussion (i.e. logic discussion on how to solve the problem within 400 words and sample output)
|
2.0
|
Provide no discussion document but provide a sample output for task (up to 1.0)
|
Provide discussion document in very brief (well below the expected word limit) and provide a sample output for task (up to 1.3)
|
Provide discussion document within word limit but not enough explanation about the logic how the problem has been solved, and provide a sample output for task (up to 1.5)
|
Provide discussion document within word limit proper explaining the logic how the problem has been solved, and a sample outputs for task (up to 2.0)
|
|
Task 2 (total marks 8)
|
Criteria
|
Marks
|
Pass
|
CR
|
DI
|
HD
|
a. Execution:Program launches, executes and terminates without crashing; program executes as specified.
|
1.0
|
Provide java file and it executes without crashing towards intended output but a significant number of options are missing (0.5)
|
Provide java file and it executes without crashing towards intended output but few options are missing (0.65)
|
Provide java file and it executes without crashing towards intended output with almost all options are included (0.75)
|
Provide java file and it executes without crashing towards intended output (1.0)
|
b. Program design & implementation:Triangle (2) and TestTriangle(2) classes are implemented as specified, showing good logic.
|
4.0
|
Implement and integrateTriangleandTestTriangleclasses with some functions using super/sub class relationship (2)
|
Implement and integrateTriangleandTestTriangleclasses with majority functions using super/sub class relationship (3)
|
Implement and integrateTriangleandTestTriangleclasses with almost all functions using super/sub class relationship (3.5)
|
Implement and integrateTriangleandTestTriangleclasses with all functions using super/sub class relationship maintaining logical flow (4)
|
c. UML design for classes
|
2.0
|
UML with a number of components (up to 1.0)
|
UML with majority of the components and their modifier, argument, and return type with minor error (up to 1.3)
|
UML with all components and their modifier, argument, and return type with minor error (up to 1.5)
|
UML with all components and their modifier, argument, and return type (2.0)
|
d. Presentation:Code uses good style (indentation, comments)
|
0.5
|
Provide arbitrary variable names, no proper indentation, and very few comments (up to 0.25)
|
Provide a number of variable names but not all by maintaining proper naming convention, occasionally proper indentation, and comments on only important calculation (up to 0.38)
|
Maintain proper naming convention of all variables, proper indentation on each block of codes, and provide comments on only important calculation (up to 0.43)
|
Maintain proper naming convention of all variables, proper indentation on each block/line of code(s), and provide important inline comments (up to 0.5)
|
e. Submission:The documents with all components such as java files, class files and discussion (i.e. logic discussion on how to solve the problem within 300 words and sample output)
|
0.5
|
Provide no discussion document but provide a sample output for task (up to 0.25)
|
Provide discussion document in very brief (well below the expected word limit) and provide a sample output for task (up to 0.37)
|
Provide discussion document within word limit but not enough explanation about the logic how the problem has been solved, and provide a sample output for task (up to 0.43)
|
Provide discussion document within word limit proper explaining the logic how the problem has been solved, and a sample outputs for task (up to 0.5)
|
Presentation
back to top
Material to submit for Task 1 & Task 2You need to submit a single zip file containing:
1. All java and class files
2. A doc/pdf file (not more than 500 words) with the description of the problems including input and output in your own words, description of how you test this program with explaining logic, a snapshot of the program output, and UML design (where required, see marking guide)
Requirements
back to top
To complete this assignment you might need to have covered material up to and including the topic Inheritance and Polymorphism, abstract classes and interfaces, Thinking of Objects, Abstract class, Interface and UML in the Text Book and topics.