- This is an open book test. You can use any of your own sketches, any of the examples from the course website or the Processing reference during the test.
- No conferring or collaboration.
- No use of Google, Facebook or any any other web resources permitted.
- There are marks going for correct use of git, so make sure and save your work and commit regularly.
In today's lab test, you will be making a prototype till system for a new Dublin winebar called Cafe Rubis that's located on 9 Parliament St. Come and check it out sometime.
-
Here is a video of the sketch you will be making today:
-
Start with a blank sketch. Set the drawing window size to be 800 x 600.
-
Name the sketch CafeRubis and commit it to a new, public git repository called CafeRubis under your own GitHub account.
-
Put your name and student number into the sketch comments.
-
Download this CSV file to the data folder of your sketch folder. The file contains data on the products that Cafe Rubis sells.
-
Create a class called
Product
with a field forname
, of typeString
and a field forprice
of typefloat
. -
Write a constructor on the
Product
class that takes aTableRow
as a parameter and assigns the fields in the class from the appropriate columns in theTableRow
. -
Declare two global
ArrayList
s ofProduct
objects and call themproducts
andbill
. -
Write a function called
loadData
that loads the data from the file and populates the productsArrayList
.Call this fromsetup
. -
Write a function called
printProducts
that prints the contents of theArrayList
after it has been loaded. You should make atoString
method on theProduct
class to help you do this. Call this from setup after you load the data to make sure the file gets loaded correctly. -
Write a function called
displayProducts
that displays the product menu that can be seen on the left side of the screen. You can use the functionnf
to format the price to two decimal places. You can use the functiontextAlign
to align text to the left or right. You should write your code so that the menu gets displayed correctly even if the screen was to change size or if more products were added. -
Write code for the
mousePressed
function that allows the user to click on a product and have it added to thebill
ArrayList. -
Write code for a function called
displayBill
that draws the bill to the screen as per the video.
Submit the URL of your git repository here. You can also upload a zip file to Webcourses as a backup I'll check webcourses if I have problems with your git repository.
Description | Marks |
---|---|
Product class & constructor | 10 |
loadData | 10 |
printData | 5 |
Declaring the two ArrayLists | 5 |
Displaying the products menu | 20 |
Clicking the products and adding to the bill | 20 |
Displaying the bill | 20 |
Correct use of git | 10 |
Total: | 100 |
To get full marks for correct use of git, you must make at least 5 commits, so make a commit every time you get something working.