The context for this assignment (all parts) is the development of a small software desktop application in the context of keeping track of fuel consumption and money spent on petrol for drivers. The program will allow the user to check the average consumption for the last tank filling, average consumption for the last 5 tank fillings, average amount paid, as well as visualise the data from recent weeks.
This assignment will test your knowledge of and skills in writing application software for a particular task, understanding the business rules of a particular problem, coding these in a computer program, developing a graphical user interface, connecting to a file and connecting to a database.
For this assignment, you will use the Java programming language and development will be on tAhe Eclipse IDE platform as practised in the computer lab classes.
You are to write a software desktop application using the Java programming language. The program enables a user, assuming that they are a motorist (car, motorbike, van, truck, etc.), to keep track of the fuel consumption and money spent on fuel. The user can enter the amount of fuel purchased at the petrol station, the kilometres driven, the total amount paid for the fuel, and the date of the purchase. To this end, you need to provide labels that guide the user as well as appropriate input GUI components (your choice of text fields, drop down menus, etc.).
Example of what the “empty” GUI might look like
You have a great degree of freedom in what GUI elements you choose and how you would like to design the layout of your GUI. The above example is really just that – an example the design of which you can copy if you are feeling uninspired to come up with your own design. What matters is the functionality of the design and that the user can input the required data in a sensible fashion.
Input values for the fuel purchased, distance driven and amount paid are floating point values. The date needs to be entered as day, month, year. The average fuel consumption for the last tank filling and the average fuel consumption for the last 5 tank fillings need to be displayed as a floating point number with 1 decimal place. The average amount paid for the last 5 tank fillings needs to be displayed as a floating point number with two decimal places and the “$” sign in front.
The drawing area needs to be at least 350 x 250 pixels in size (bigger is OK, but not smaller). The drawing area should have a clearly visible border. The drawing area should show labels for the current tank filling and the 4 most recent tank fillings. For simplicity, these can be labelled as “Wk1”, “Wk2”, ...., “Wk5” as an in the example above. There should be a baseline, drawn in black colour. The average consumption for the current tank filling and each of the 4 most recent tank fillings is to be shown as a bar graph (see example), with the bars drawn in the colour chosen by the user.
To visualise the average fuel consumption for the current tank filling and across the current and the 4 most recent tank fillings, horizontal lines are to be drawn in the colours chosen by the user (see example).
Your task in Part A will be to develop a GUI that allows a user to input the data in a suitable GUI using Java Swing components and the Java WindowBuilder, and then to visualise the data. To this end, the user can
ï‚· input the data using Java Swing GUI elements, e.g. text fields, radio buttons, drop down lists, etc.,
ï‚· calculate various averages,
ï‚· visualise the consumption as a bar graph,
ï‚· select different colours for various elements, and
ï‚· exit the program in a defined way via a Quit button.
The data should be entered through the GUI and
ï‚· the averages calculated when the Calculate button is clicked, and
ï‚· visualised when the Draw button is clicked.
Data beyond the 5 weeks do not need to be saved in Part A, neither in memory (in an array or vector, for example), nor in a text file.
ï‚· For this assignment, you do not have to do any checking for invalid user input (you may of course, if you want to), for example you do not have to check whether the user has typed in a negative number or a letter in the text boxes for fuel purchased, distance driven and amount paid. Checking for invalid user input will be discussed in lectures later in the semester.
ï‚· Your user interface does not have to be identical to the one above. This is just an example of how the GUI could look.
ï‚· Your GUI should update any labels in an appropriate manner when the user enters new data and clicks on the Calculate button.
What the tutors will be looking for
The tutor’s instructions include
ï‚· Constants vs literals. Using constants is important for the ease of maintenance. Not using constants will result in lower marks. For example, consider using a constant for the width of each bar in the bar graph. (2 marks)
ï‚· GUI Design. Is it simple to use and easy to understand? Are all required components there? (4 marks)
ï‚· Program code layout. Separate blocks of code by a blank line. Use comments. (3 marks)
ï‚· A comment is not an essay. Comments are important for the maintenance of your program and should contain enough details, but keep them concise. Don’t comment every single line. (2 marks)
ï‚· The program must have a prologue. (2 marks)
ï‚· Good names for your variables and constants. Check style against the Java style guide attached below. (4 marks)
ï‚· Does the program work correctly? Are the averages calculated correctly? Are the bar graphs drawn the right way? (10 marks)
Total: 27 marks