Point of Sale UI Point of sale interfaces are designed to si

Point of Sale UI

Point of sale interfaces are designed to simplify the process of making transactions, often in a retail environment. We often see them used in restaurants where managers can input the menu and waiters can quickly enter customer orders, which are transmitted to the kitchen and recorded. Modern systems usually include a touchscreen interface, which we will simulate with a mouse-based GUI.

The program you should design and build will read a menu from a text file formatted with a menu item and a price separated by a |. To simplify your text-parsing code, we will omit the dollar sign from the price.

For example:

The program should load the file at launch and create a panel full of large buttons (ideal for a touchscreen) for each menu item. A waiter should be able to click on each menu item to add it to the current order. This should add the item to a receipt panel which displays the full order and the total cost. The total cost should be accurate at all times, updated as each item is added (not only when the order is finalized).

The system only takes credit card as payment type however it can handle/validate multiple types of credit cards. (Please see credit card section below).

The waiter should be able to click a “Place Order” button that simulates transmitting the order to the kitchen by printing the order to System.out (in addition to showing the confirmation on screen). You should also include a “Clear” button that will clear the current order (used when a waiter makes a mistake and needs to start over).

import javafx.application.Application;
import javafx.stage.Stage;

public class McPatterns extends Application {
public static void main(String [] args) {
   //FileLoader.getFile(args[0]);
launch(args);
}

@Override
public void start(Stage primaryStage) throws Exception {
McPatternsGUI app = new McPatternsGUI(new McPatternsPresenter());
app.start(primaryStage); //To change body of generated methods, choose Tools | Templates.
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

____
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class McPatternsGUI extends Application {
McPatternsPresenter presenter;
  
public McPatternsGUI(McPatternsPresenter presenter) {
this.presenter = presenter;
presenter.attachView(this);
}
  
@Override
public void start(Stage primaryStage) {
BorderPane ui = new BorderPane();
// Top Pane
HBox titlePane = new HBox();
titlePane.getChildren().add(new Label(\"Welcome to McPatterns\"));
titlePane.setAlignment(Pos.CENTER);
titlePane.setStyle(STYLESHEET_MODENA);
  
//Right Pane
VBox orderPane = new VBox();
orderPane.getChildren().add(new Label(\"Your Order:\"));
// Add order details below this label
orderPane.getChildren().add(new TextField(\"Enter your CC#\"));
  
Button confirm = new Button(\"Confirm\");
confirm.setOnMouseReleased(e -> {
// Add a call to confirm the order
});
  
orderPane.getChildren().add(confirm);
  
Button cancel = new Button(\"Cancel\");
cancel.setCancelButton(true);
orderPane.getChildren().add(cancel);
  
//Center Pane
FlowPane menuPane = new FlowPane();
menuPane.getChildren().add(new Button(\"Replace with menu buttons\"));
  
ui.setTop(titlePane);
ui.setRight(orderPane);
ui.setCenter(menuPane);
Scene scene = new Scene(ui, 500, 500);
  
primaryStage.setTitle(\"McPatterns\");
primaryStage.setScene(scene);
primaryStage.show();
}
}

}

______________

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

class McPatternsPresenter {
//This is the class that will handle the model <-> UI communication.
MenuModel model;
McPatternsGUI view;
ArrayList<String> item = new ArrayList<String>();
double checkout;
  
void loadMenuItems() {
// TODO: Add code to read a file and load the menu items.
   FileLoader.loadMenuItems();
   model = new MenuModel();
}

void attachView(McPatternsGUI view) {
this.view = view;
}
// Add functions to return the menu items.
  
String getName(int i)
{
   return model.item.get(i);
}
  
Double getPrice(int i)
{
   return model.price.get(i);
}

int getSize()
{
   return model.productList.size();
}
}

____________________

import java.io.*;
import java.util.*;

class FileLoader {
   static ArrayList<MenuModel> productList;
   static String filename;
  
static void loadMenuItems(){
productList = new ArrayList<MenuModel>();
File inputFile = new File(\"menu.txt\");
try{
Scanner in = new Scanner(inputFile);
while(in.hasNextLine()){
String line = in.nextLine();
System.out.println(line);
String[] products = line.split(\"\\\\|\"); //Item|Cost
String name = products[0];
double cost = Double.parseDouble(products[1]);
MenuModel theItem = new MenuModel(name, cost);
productList.add(theItem);
  
}
} catch (Exception ex) {
ex.printStackTrace();
System.out.println(\"Unable to load order from \" + inputFile + \".\");
}
}
static void getFile(String filename)
{
   //start the filename, and put it on loadMenuItems
   //inputFile = new File(filename);
}
}

_____________

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;

class MenuModel {
// Add your implementation for Menu Items here.
// Determine what data you want to store for each item
   // Data: name|price
   public ArrayList<String> item = new ArrayList<String>();
   public ArrayList<Double> price = new ArrayList<Double>();
   String name;
   double checkout;
   ArrayList<MenuModel> productList;
  
   MenuModel(String name, double checkout)
   {
       this.name = name;
       this.checkout = checkout;
   }
   public MenuModel()
   {
      
       for ( int i = 0; i < FileLoader.productList.size(); i++)
       {
           item.add(productList.get(i).name);
       }
      
       for ( int i = 0; i < FileLoader.productList.size(); i++)
       {
           price.add(productList.get(i).checkout);
       }
   }
}

Solution

..........................................

I have made changes in the UI class. Your program is almost correct. You can run it and I have left \"Clear\" for you. You can take the hint from my code. And if you don\'t understand any part of it you can ask here.

UPD:

Looks like I can\'t comment further. In loadmenuItems() , new File(filename) , this filename variable is instance variable which we have declared in the FileLoader class. That variable is empty in start or null. When we call getFile() method , we assign this filename variable with value passed by arguments. You can see my fileloader class code you will understand that. In java undeclared variable takes default value and for string its null.

Point of Sale UI Point of sale interfaces are designed to simplify the process of making transactions, often in a retail environment. We often see them used in
Point of Sale UI Point of sale interfaces are designed to simplify the process of making transactions, often in a retail environment. We often see them used in
Point of Sale UI Point of sale interfaces are designed to simplify the process of making transactions, often in a retail environment. We often see them used in
Point of Sale UI Point of sale interfaces are designed to simplify the process of making transactions, often in a retail environment. We often see them used in

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site