Objectives
•Analyse, develop, and implement software solutions.
•Choose appropriate data structures in program design.
•Apply classes, inheritance, polymorphism, and exception handling.
Assessment Task
In this assignment, you are required to write a Java Application that uses an interactive Graphical User Interface (GUI) based on the JFrame class using SWING GUI components.
Your task is to develop a Java Application that allows the users to select the books from an online bookstore using the three drop down subject lists (Programming, AI, History), calculate the cost of purchasing the selected books and display the total cost including the postal charges. The application should contain a GUI as shown below. The GUI components should consist of 1 Label, 3 Combo boxes (drop down lists) and 3 Buttons. The layout managers are not used in this assignment. The components should be in the same order as shown below.
The functions of three buttons are described below.
1. Calculate Cost
The Calculate Cost button calculates the cost of selected books from each dropdown list by adding them. A 10% GST of the total cost and $8 postage are also added to the cost. After calculation is done, a dialog box should pop out and a message should be displayed as follows.
The books and associated costs are listed below in Tables 1-3.
Table 1. Programming Books and Cost
|
|
Programming Books
|
Cost ($)
|
|
|
Java How to Program by Deitel
|
100
|
|
|
The C Programming Language by Kernighan
|
|
50
|
|
|
Effective C++ by Meyer
|
|
|
|
70
|
|
|
Design Patterns in C# by
|
Metsker
|
|
80
|
Table 2. AI Books and Cost
|
|
|
AI Books
|
Cost ($)
|
|
Neural Network Design by Hagan
|
29
|
|
Machine Learning for Dummies by Mueller
|
45
|
|
Artificial Intelligence for Humans by Heaton
|
23
|
|
Learning from Data by Lin
|
28
|
Table 3. History Books and Cost
|
|
History Books
|
Cost ($)
|
A World History by Kurlansky
|
30
|
Six Months that Changed the World by MacMillan
|
40
|
A History of the World by Standage
|
50
|
Hiroshima by Hersey
|
25
|
2. Display Cost
The Display Cost button should display the total cost for selected books (cost of all selected books + 10% GST+$8) as shown below.
3. Quit
The Quit button should allow the user to exit from the application.
Your application MUST have two Classes (Bookstore and BookstoreApplication) as described below.
//Bookstore.java file public class Bookstore
{
//Declare variables, constants and data structures as needed //Constructor
//get and set methods
}
BookstoreApplication.java file
//Import packages
public class BookstoreApplication
{
//Declare variables, constants and data structures as needed //Declare window width and height
//Composition
//Constructor
//Method to create label, comboboxes, buttons and register action listeners //Method to create panels and add components
//Inner listener classes for comboboxes and buttons with actionPerformed method
public static void main(String[] args)
{
}
}
Implementation Platform
You MUST implement your program in Java using TextPad Editor which is available in University’s computing labs and may also be downloaded from the following site:
Assignment Submission
You MUST submit the following two files using the Moodle online submission system. You will be penalised if you do not submit appropriate files as mentioned below.
•Bookstore.java - Source code for Bookstore class
•BookstoreApplication.java - Source code for BookstoreApplication class
Assessment Item 1 Marking Criteria
|
Total Marks – 15
|
Marks Allocated
|
1
|
Graphical User Interface presentation (main window and two dialog
|
|
|
boxes) - 0.5 mark for each part (0 mark if program doesn’t run)
|
1.5
|
2
|
Correct use of Inheritance and Composition – 0.5 mark for each part
|
1
|
3
|
Quality of code (comments, indentation, naming and readability) – 0.5
|
|
|
mark for each part
|
2
|
|
|
4
|
Class constants and variables including meaningful names – 0.5 mark for
|
|
|
each part
|
1
|
|
|
5
|
Methods (1 main method, at least 2 methods in Bookstore class and 2
|
2.5
|
|
methods in BookstoreApplication class) – 0.5 mark for each method
|
|
|
|
|
6
|
Classes including 5 listener classes - 0.5 mark for each class
|
2.5
|
|
|
|
7
|
Constructors - 0.5 mark for each constructor
|
1
|
|
|
|
8
|
Calculate Cost button works (0 mark if program doesn’t run)
|
1.5
|
|
|
|
9
|
Display Cost button works (0 mark if program doesn’t run)
|
1
|
|
|
|
10
|
Quit button works (0 mark if program doesn’t run)
|
1
|
11
|
Penalty for submission of incorrect file names or format is 2 marks
|
-2
|
12
|
Penalty for late submission
|
5% per day
|