Question: Getting Started To begin this lab, create a new JavaFX project named abc123-lab8 , and create the following packages, classes, and FXML files: application.Main application.controller.MarketController

Getting Started

To begin this lab, create a new JavaFX project namedabc123-lab8, and create the following packages, classes, and FXML files:

application.Main

application.controller.MarketController

application.controller.CartController

application.controller.ConfirmationController

application.model.Cart

application.model.Item

Market.fxml

Cart.fxml

Confirmation.fxml

Market Apple: $0.89 Banana: $0.27 Carrot: $0.89 Dog food: $7.29 Eggplant: $2.69 Fennel: $1.49 Grapes: $3.99 Horseradish: $0.59 lce: $0.50 Juice: $2.39 Kale: $1.23 Lemon: $0.16 View My Cart

If the user clicks theview my cartbutton, the app will display a listing of what is currently contained in their cart:

This view will be theCart.fxml.

From the cart view, if the user clicks theCheck outbutton, the app will display a confirmation message:

This view will be theConfirmation.fxml.

In the latter two views, thereturn to marketbutton will return the user to the Market.fxml view. No data file is required for input into the app - it can be hard-coded into the model.

You may choose the images, fonts, colors, app size, and other style features. You may assume the number of different items to purchase is static (showing only 12 items on the market view). If the user wishes to order 2 of an item, they will click on that item twice. Additionally, you may choose any items in your market, provided all items have a price. Each view must have the GUI components minimally shown in the example views above.

Making it Work

Main.javawill launch the application and showMarket.fxml. MarketController.javawill be theEventHandlerfor this fxml, and should be connected to all buttons in this view. If the user chooses theview my cartbutton, MarketController will replace the current scene on the stage withCart.fxml.

The Model

The model of this application will beItem.javaandCart.java. The app will have a single Cart object, which will contain amapof Item objects. Following the MVC design pattern, neither the Item class nor the Cart class may directly update the view - this should always be handled by a controller. You will need to decide what other methods will be needed in these classes. Itemobjects must each have a name and a price. For example, the following could be used to instantiate a new Item:

Item apple = new Item(\"Apple\", 0.89);

Cartobject will contain a map of Item objects. It is up to you to decide whichtypeof map to use. This class must have an object methodprintReceiptwhich creates a new file and writes out the information in the cart to this new file. The file should be in the top of the project (created without a file path). The first receipt should be namedreceipt1.txt, and subsequent receipts should be appropriately numbered. The format of the file is as follows (where the data here corresponds to the above views): Apple,3,2.67 Carrot,5,4,45 Juice,1,2.39 Lemon,2,0.32 TOTAL,11,9.83 The cart will be displayed byCart.fxmlandCartController.javawill be the EventHandler for this. The purpose of this view is to show a listing of all chosen items, their quantities, and the current total (cost) of all items in the cart. Note that it is not required to implement functionality to remove items from the cart.

Confirmation

The confirmation view will be displayed byConfirmation.fxmlandConfirmationController.javawill be the EventHandler for this. The purpose of this view is to show the user the total of their purchase and the name of the data file where their receipt was saved (written).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!