This lab is based on the lessons on JavaFX GUI and File Input/Output.
This assignment is to be done individually; you are not allowed to work on this assignment with anyone. See also the Academic Integrity page and the Assignment and Exam Policies
Use NetBeans to create a new JavaFX Application project.
Project Name: A5_LoginName (where LoginName is your own sheridan login name).
Package Name: loginname (your own login name, in lower-case letters). Do not use prog24178.loginname or anything else, just loginname.
Main Application Class Name: Assign5
This is a JavaFX application. You will also be adding a .jar file of classes that have already been written for you. You must add this to your project in order to complete this assignment.
When you create your project, make sure the main Application class is called Assign5.
To complete this project, you will need to download the Assignment 5 Distribution File. This file contains the following items:
Failure to follow the above instructions could result in penalties. I'll be testing your assignment using JUnit and it relies on having your package and class names following the specifications above.
This application is used to keep track of cookie inventory: Crepe and her daughter Aubrey have a small home bakery which sells a variety of cookies in a small kiosk at the local farmer's market. They don't bake all the flavours every day because they only have the one oven in their kitchen, so they decide the night before which flavours they will bake the next day.
Early in the morning as the cookies are made, Crepe goes into the Cookie Inventory program on her tablet and adds the number and type of cookies baked. These are saved to a data file called "cookies.txt", which has the following structure:
File: cookies.txt | ||
---|---|---|
Description | Data Type | Comments |
flavour ID number | integer | all cookie flavours have a unique ID number assigned to them |
quantity baked | integer | the number of cookies of this flavour that were baked in the morning |
The file uses the new-line as the record delimiter and the pipe symbol (|) as the field delimiter.
After all the cookies are baked, Crepe and Aubrey pack them up and take them to the farmer's market.
At the farmer's market, people purchase cookies. As each purchase is made, Crepe or Aubrey will enter the number of each flavour of cookie purchased, and this updates the initial inventory they started with. At the end of the day, the file contains the same records, but the quantities have been adjusted to reflect the numbers of each flavour of cookie sold.
Sometimes, if the market is exceptionally busy, Aubrey will run home and bake a quick batch of cookies that are selling out. When this happens, they need to update the quantity of that cookie in the inventory program.
This is the UI for the program you will be creating:
There are three additional classes in this assignment besides the Assign5 Application class (specific details further down):
All classes must be part of the same package.
The class in blue are already written for you. You only need to code the classes in green.
The Cookie enumeration is already written for you and is included in the cookies.jar file.
This enumeration contains constants for each cookie flavour. Every flavour is assigned a name (displayed on the UI), a unqiue ID number, and a price.
See the Javadocs files you were given to see more information or to see what constants are in the Cookies enum.
The CookieInventoryItem class is already written for you and is included in the cookies.jar file
This class models a single record in the cookies.txt file. A CookieInventoryItem has a data member for the cookie flavour ID and the quantity of cookies currently available.
See the Javadocs files you were given to see more information on the CookieInventoryItem class.
The CookieInventoryFile class models the collection of records (modeled by CookieInventoryItem) in the cookies.txt file. Unlike previous list classes you've written, this one extends ArrayList instead of including an ArrayList data member. The benefit of this is that you don't need a lot of the methods you needed in other list classes, plus this one is easier to iterate through.
Extending ArrayList:
Just extend ArrayList as you would extend any other class.
Make sure you include the concrete type. For example:
public class CookieInventoryFile extends ArrayList<CookieInventoryItem> { ... }
The specs for the CookieInventoryFile class are shown in the diagram below:
Class: CookieInventoryFile |
---|
(no data members) |
Method Members: + CookieInventoryFile() + CookieInventoryFile(File file) + find(flavourId : int) : CookieInventoryItem + loadFromFile(file : File) : void + writeToFile(file: File) : void |
This is the main Assign5 class for your JavaFX Application.
This program allows Crepe and Aubrey to update their cookie inventory for the day.
Your program has the following UI elements (specific details about functionality are outlined later):
The UI elements must be laid out and displayed similar to what is shown in the screen shots (you can change the border style/colour if you wish). Your UI must contain a meaningful title in the title bar.
Any formatting of the UI elements must be done via external CSS file.
Be sure that you use the necessary methods to apply styling to the various components on your UI in the most efficient way possible.
Startup:
On startup, the following tasks need to be performed:
You must deal with the following situations in a user-friendly and efficient manner without redundant code. See the sample screen shots below for error messages:
In all cases above, focus returns to the field that caused the problem. If the user entered text in the field, that text should be selected.
Error handling code must be efficient. Use re-usable methods to avoid redundant code.
Bonus Marks: You can do any of the following for bonus marks (or all of them!). Note that bonus marks are only assigned when the code is efficient, well-written, follows standards, and is correct. Part-marks are not given for bonus: it's all or nothing.
Follow these instructions carefully or you risk penalties up to 100% of your grade!
Your submission must follow all the submission requirements outlined in the Submission Standards.
It is expected that all code will conform to the industry standards outlined in Java Standards for this Course.
You are to submit 2 files, separately:
See Archiving a NetBeans Project if you're not sure how to do zip/rar a NetBeans project.
You must also copy and paste all of your source code from your CookieInventoryFile class and your Assign5 Application class into a plain text file (e.g. .TXT) or Word document (e.g. .DOC/.DOCX).
You don't have to format this code - it's used by TurnItIn (the originality checker in SLATE, which is a piece of software that checks your submission for plagiarism against other submissions in the college, in other colleges, from the web, and various other sources).
Submit this document in addition to your source code zip/rar file. DO NOT add it inside your zip/rar file - it must be a separate file. This is used for TurnItIn (it won't accept java programs and won't examine the contents of zip/rar files).
Submit your assignment to the Assignment 5 drop box in SLATE. Upload the ZIP/RAR file and upload the TXT/DOC file separately to the same drop box.
Failure to follow any of the instructions above will result in penalties or a grade of 0.
It is expected that all code will conform to the industry standards outlined in Java Standards for this Course.
Your submission will be evaluated based on the following criteria:
Assignment 5 Evaluation | |
CookieInventoryFile Class | |
Criteria | Mark |
---|---|
/15 | |
Application Class: User Interface | |
Criteria | Mark |
/13 | |
Application Class: Functionality/Code | |
Criteria | Mark |
/22 | |
Penalties | |
Criteria | Mark |
General/Miscellaneous: | -- |
For Violating Industry Standards: | -- |
Total: | /50 |
Other Penalties | |
Criteria | Mark |
| -- |
Assignment 5 Total: | /50 |