Question

I. User Interface Create a JavaFX application with a graphical user interface (GUI) based on the...

I. User Interface

Create a JavaFX application with a graphical user interface (GUI) based on the attached “GUI Mock-Up”. Write code to display each of the following screens in the GUI:

A. A main screen, showing the following controls:

• buttons for “Add”, “Modify”, “Delete”, “Search” for parts and products, and “Exit”

• lists for parts and products

• text boxes for searching for parts and products

• title labels for parts, products, and the application title

B. An add part screen, showing the following controls:

• radio buttons for “In-House” and “Outsourced” parts

• buttons for “Save” and “Cancel”

• text fields for ID, name, inventory level, price, max and min values, and company name or machine ID

• labels for ID, name, inventory level, price/cost, max and min values, the application title, and company name or machine ID

C. A modify part screen, with fields that populate with presaved data, showing the following controls:

• radio buttons for “In-House” and “Outsourced” parts

• buttons for “Save” and “Cancel”

• text fields for ID, name, inventory level, price, max and min values, and company name or machine ID

• labels for ID, name, inventory level, price, max and min values, the application title, and company name or machine ID

D. An add product screen, showing the following controls:

• buttons for “Save”, “Cancel”, “Add” part, and “Delete” part

• text fields for ID, name, inventory level, price, and max and min values

• labels for ID, name, inventory level, price, max and min values, and the application

• a list for associated parts for this product

• a “Search” button and a text field with an associated list for displaying the results of the search

E. A modify product screen, with fields that populate with presaved data, showing the following controls:

• buttons for “Save”, “Cancel”, “Add” part, and “Delete” part

• text fields for ID, name, inventory level, price, and max and min values

• labels for ID, name, inventory level, price, max and min values, and the application

• a list for associated parts for this product

• a “Search” button and a text field with associated list for displaying the results of the search

II. Application

Now that you’ve created the GUI, write code to create the class structure provided in the attached “UML (unified modeling language) Class Diagram”. Enable each of the following capabilities in the application:

F. Using the attached “UML Class Diagram”, create appropriate classes and instance variables with the following criteria:

• five classes with the 16 associated instance variables

• variables are only accessible through getter methods

• variables are only modifiable through setter methods

G. Add the following functionalities to the main screen, using the methods provided in the attached “UML Class Diagram”:

• redirect the user to the “Add Part”, “Modify Part”, “Add Product”, or “Modify Product” screens

• delete a selected part or product from the list

• search for a part or product and display matching results

• exit the main screen

H. Add the following functionalities to the part screens, using the methods provided in the attached “UML Class Diagram”:

1. “Add Part” screen

• select “In-House” or “Outsourced”

• enter name, inventory level, price, max and min values, and company name or machine ID

• save the data and then redirect to the main screen

• cancel or exit out of this screen and go back to the main screen

2. “Modify Part” screen

• select “In-House” or “Outsourced”

• modify or change data values

• save modifications to the data and then redirect to the main screen

• cancel or exit out of this screen and go back to the main screen

I. Add the following functionalities to the product screens, using the methods provided in the attached “UML Class Diagram”:

1. “Add Product” screen

• enter name, inventory level, price, and max and min values

• save the data and then redirect to the main screen

• associate one or more parts with a product

• remove or disassociate a part from a product

• cancel or exit out of this screen and go back to the main screen

2. “Modify Product” screen

• modify or change data values

• save modifications to the data and then redirect to the main screen

• associate one or more parts with a product

• remove or disassociate a part from a product

• cancel or exit out of this screen and go back to the main screen

J. Write code to implement exception controls with custom error messages for one requirement out of each of the following sets (pick one from each):

1. Set 1

• entering an inventory value that exceeds the minimum or maximum value for that part or product

• preventing the minimum field from having a value above the maximum field

• preventing the maximum field from having a value below the minimum field

• ensuring that a product must always have at least one part

2. Set 2

• including a confirm dialogue for all “Delete” and “Cancel” buttons

• ensuring that the price of a product cannot be less than the cost of the parts

• ensuring that a product must have a name, price, and inventory level (default 0)

K. Demonstrate professional communication in the content and presentation of your submission.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Working code implemented in Java and appropriate comments provided for better understanding:

Here I am attaching code for these files:

src - InventoryManagementsystem - exceptions ValidationException.java models InHouse.java Inventory.java OutsourcePart.java P

Source code for ValidationException.java:

package InventoryManagementSystem.exceptions;

public class ValidationException extends Exception {

/**
* Constructor. Simply passes the exception message to the base handler.
*
* @param message
*/
public ValidationException(String message) {
super(message);
}
}

Source code for InHouse.java:

package InventoryManagementSystem.models;


public class InHouse extends Part {

/* An InHoused Part with params
* @param machineId - Machine ID - Integer
*/
private int machineId;

public InHouse() {
}

;
public InHouse(int _id, String _name, double _price, int _stock, int _min, int _max, int _machineId) {
super(_id, _name, _price, _stock, _min, _max);
machineId = _machineId;
}

;

public int getMachineId() {
return machineId;
}

public void setMachineId(int _machineId) {
machineId = _machineId;
}

}

Source code for Inventory.java:

package InventoryManagementSystem.models;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;


public class Inventory {

// Observable list for parts in inventory
private static ObservableList<Part> allParts = FXCollections.observableArrayList();

// Observable list for products in inventory
private static ObservableList<Product> allProducts = FXCollections.observableArrayList();

public Inventory() {
allParts = FXCollections.observableArrayList();
allProducts = FXCollections.observableArrayList();
}

//Add a Part
public static void addPart(Part _Part) {
allParts.add(_Part);
}

//Add a Product
public static void addProduct(Product _Product) {
allProducts.add(_Product);
}

//Find a Part
public static Part lookupPart(int partID) {
for (Part p : allParts) {
if (p.getId() == partID) {
return p;
}
}
return null;
}

//Get Observable list of parts
public static ObservableList<Part> getParts() {
return allParts;
}

//Get Observable list of Products
public static ObservableList<Product> getProducts() {
return allProducts;
}

//Get Observable list of parts
public static ObservableList<Part> getAllParts() {
return allParts;
}

//Get Observable list of Products
public static ObservableList<Product> getAllProducts() {
return allProducts;
}

//Find a Product
public static Product lookupProduct(int productID) {
for (Product p : allProducts) {
if (p.getId() == productID) {
return p;
}
}
return null;
}

//Delete a Part
public static void deletePart(int _ID) {
for (Part part : allParts) {
if (part.getId() == _ID) {
allParts.remove(part);
}
}
}

//Delete a Product
public static void deleteProduct(int _ID) {
for (Product product : allProducts) {
if (product.getId() == _ID) {
allProducts.remove(product);
}
}
}

//Check to see if Product has an associated part to see if it can be safely deleted.
public static boolean canDeleteProduct(Product product) {
return product.getAssociatedPartsCount() == 0;
}

//Modify a Part
public static void updatePart(Part updatedPart) {
allParts.set(updatedPart.getId(), updatedPart);
}

//Modify a Product
public static void updateProduct(Product updatedProduct) {
allProducts.set((updatedProduct.getId() - 1), updatedProduct);
}

//Count number of Parts
public static int getPartsCount() {
return allParts.size();
}

//Count number of Products
public static int getProductsCount() {
return allProducts.size();
}
}

Source code for OutsourcePart.java:

package InventoryManagementSystem.models;


public class OutsourcePart extends Part {

/**
* An Outsourced Part with params
*
* @param companyName - Company Name - String
*/
private String companyName;

public OutsourcePart() {
}

;
public OutsourcePart(int _id, String _name, double _price, int _stock, int _min, int _max, String _companyName) {
super(_id, _name, _price, _stock, _min, _max);
companyName = _companyName;
}

;

public String getCompanyName() {
return companyName;
}

public void setCompanyName(String _companyName) {
companyName = _companyName;
}

}

Source code for Part.java:

package InventoryManagementSystem.models;

import InventoryManagementSystem.exceptions.ValidationException;


public abstract class Part {

/**
* A new product with params
*
* @param id - Product ID - Integer
* @param name - Product Name - String
* @param price - Product Price - Double
* @param stock - Current stock level of Product - Integer
* @param min - Minimum allowable stock level of product - Integer
* @param max - Maximum allowable stock level of product - Integer
*/
private int id;
private String name;
private double price;
private int stock;
private int min;
private int max;
//Default constructor
Part() {};
//constructor.
Part(int _id, String _name, double _price, int _stock, int _min, int _max) {
id = _id;
name = _name;
price = _price;
stock = _stock;
min = _min;
max = _max;
}

;

//Get Part ID
public int getId() {
return id;
}

;

//Get Part Name
public String getName() {
return name;
}

;

//Get Part Price
public double getPrice() {
return price;
}

;

//Get Part Stock Level
public int getStock() {
return stock;
}

;

//Get Allowable Part Minimum Inventory
public int getMin() {
return min;
}

;

//Get Allowable Part Maximum Inventory
public int getMax() {
return max;
}

;

//Set Part ID
public void setId(int _id) {
id = _id;
}

;

//Set Part Name
public void setName(String _name) {
name = _name;
}

;

//Set Part Price
public void setPrice(double _price) {
price = _price;
}

;

//Set Part Stock Level
public void setStock(int _stock) {
stock = _stock;
}

;

//Set Allowable Part Minimum Inventory
public void setMin(int _min) {
min = _min;
}

;

//Set Allowable Part Maximum Inventory
public void setMax(int _max) {
max = _max;
}

;

//Part Data Validation
public boolean isValid() throws ValidationException {

//Prohibit Unnamed Products - "Rule of Acquistion #239: Never be afraid to mislabel a product."
if (getName().equals("")) { //Exception Controls Set 2
throw new ValidationException("The name field cannot be null.");
}

//Ensure price is greater than zero - "Rule of Acquistion #37: If it's free, take it and worry about hidden costs later."
if (getPrice() < 0) { //Exception Controls Set 2
throw new ValidationException("The price must be greater than zero dollars.");
}

//Ensure positive inventory level - "Rule of Acquistion #242: More is good... all is better."
if (getStock() < 0) { //Exception Controls Set 1
throw new ValidationException("The current inventory must be greater than zero.");
}

//Prohibit Out of Stock Inventory level - "Rule of Acquistion #109: Dignity and an empty sack is worth the sack."
if (getMin() < 0) { //Exception Controls Set 1
throw new ValidationException("The minimum inventory must be greater than zero units.");
}

//Ensure maximum inventory is greater than minimum inventory - "Rule of Acquistion #125: You can't make a deal if you're dead."
if (getMin() > getMax()) { //Exception Controls Set 1
throw new ValidationException("The minimum inventory must be less than the maximum number of units.");
}

//Ensure current inventory quantity falls between the defined Minimum and Maximum values - "Rule of Acquistion #126: Count it."
if (getStock() < getMin() || getStock() > getMax()) { //Exception Controls Set 1
throw new ValidationException("The current inventory must be between the minimum and maximum inventory threshold.");
}

return true;
}
}

Source code for Product.java:

package InventoryManagementSystem.models;

import InventoryManagementSystem.exceptions.ValidationException;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import InventoryManagementSystem.models.Part;


public class Product {

/**
* A new product with params
*
* @param id - Product ID - Integer
* @param name - Product Name - String
* @param price - Product Price - Double
* @param stock - Current stock level of Product - Integer
* @param min - Minimum allowable stock level of Product - Integer
* @param max - Maximum allowable stock level of Product - Integer
*/
private int id;
private String name;
private double price;
private int stock;
private int min;
private int max;

public Product() {
}

; //Default constructor
public Product(int _id, String _name, double _price, int _stock, int _min, int _max) {
id = _id;
name = _name;
price = _price;
stock = _stock;
min = _min;
max = _max;
}

; //constructor

//Get Product ID
public int getId() {
return id;
}

;

//Get Product Name
public String getName() {
return name;
}

;

//Get Product Price
public double getPrice() {
return price;
}

;

//Get Product Stock Level
public int getStock() {
return stock;
}

;

//Get Allowable Product Minimum Inventory
public int getMin() {
return min;
}

;

//Get Allowable Product Maximum Inventory
public int getMax() {
return max;
}

;

//Set Product ID
public void setId(int _id) {
id = _id;
}

;

//Set Product Name
public void setName(String _name) {
name = _name;
}

;

//Set Product Price
public void setPrice(double _price) {
price = _price;
}

;

//Set Product Stock Level
public void setStock(int _stock) {
stock = _stock;
}

;

//Set Allowable Product Minimum Inventory
public void setMin(int _min) {
min = _min;
}

;

//Set Allowable Product Maximum Inventory
public void setMax(int _max) {
max = _max;
}

;
public void setProductParts(ObservableList<Part> parts) {
this.associatedParts = parts;
}

public ObservableList getProductParts() {
return associatedParts;
}
//Create observable list of associated parts
private ObservableList<Part> associatedParts = FXCollections.observableArrayList();

//Add to observable list of associated parts
public void addAssociatedPart(Part _associatedPart) {
associatedParts.add(_associatedPart);
}

;

//Remove from observable list of associated parts
public void deleteAssociatedPart(int partID) {
for (Part p : associatedParts) {
if (p.getId() == partID) {
associatedParts.remove(p);
}
}
}

;

//Get count of observable list of associated parts
public int getAssociatedPartsCount() {
return associatedParts.size();
}

//Get observable list of associated parts
public ObservableList<Part> getAllAssociatedParts() {
return associatedParts;
}

public void purgeAssociatedParts() {
associatedParts = FXCollections.observableArrayList();
}

public Part lookupAssociatedPart(int _partId) {
for (Part p : associatedParts) {
if (p.getId() == _partId) {
return p;
}
}

return null;
}

//Product Data Validation
public boolean isValid() throws ValidationException {
double totalPartsPrice = 0.00;

//Price Summary of a Product's Associated Parts
for (Part p : getAllAssociatedParts()) { //Used to verify for Exception Controls Set 2
totalPartsPrice += p.getPrice();
}

//Prohibit Unnamed Products - "Rule of Acquistion #239: Never be afraid to mislabel a product."
if (getName().equals("")) { //Exception Controls Set 2
throw new ValidationException("The name field cannot be null.");
}

//Ensure price is greater than zero - "Rule of Acquistion #37: If it's free, take it and worry about hidden costs later."
if (getPrice() < 0) { //Exception Controls Set 2
throw new ValidationException("The price must be greater than zero dollars.");
}

//Ensure Profitable Margin - "Rule of Acquistion #89: Ask not what your profits can do for you, ask what you can do for your profits."
if (totalPartsPrice > getPrice()) { //Exception Controls Set 2
throw new ValidationException("The product price must be greater than the total cost of it's associated parts.");
}

//Prohibit Out of Stock Inventory level - "Rule of Acquistion #109: Dignity and an empty sack is worth the sack."
if (getStock() < 0) { //Exception Controls Set 1
throw new ValidationException("The current inventory must be greater than zero.");
}

//Ensure positive inventory level - "Rule of Acquistion #242: More is good... all is better."
if (getMin() < 0) { //Exception Controls Set 1
throw new ValidationException("The minimum inventory must be greater than zero units.");
}

//Ensure maximum inventory is greater than minimum inventory - "Rule of Acquistion #125: You can't make a deal if you're dead."
if (getMin() > getMax()) { //Exception Controls Set 1
throw new ValidationException("The minimum inventory must be less than the maximum number of units.");
}
// a product must have at least one part
if (getAssociatedPartsCount() < 1) {
throw new ValidationException("The product must contain at least 1 part. Currently at " + getAssociatedPartsCount() + "units");
}
//Ensure current inventory quantity falls between the defined Minimum and Maximum values - "Rule of Acquistion #126: Count it."
if (getStock() < getMin() || getStock() > getMax()) { //Exception Controls Set 1
throw new ValidationException("The current inventory must be between the minimum and maximum inventory threshold.");
}

return true;
}
}

Source code for MainController.java:

package InventoryManagementSystem.views;

import java.io.IOException;
import java.net.URL;
import java.util.Optional;
import java.util.ResourceBundle;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.stage.Modality;
import javafx.stage.Stage;

import InventoryManagementSystem.models.Inventory;
import static InventoryManagementSystem.models.Inventory.getParts;
import static InventoryManagementSystem.models.Inventory.getProducts;
import static InventoryManagementSystem.models.Inventory.deletePart;
import static InventoryManagementSystem.models.Inventory.deleteProduct;
import InventoryManagementSystem.models.Part;
import InventoryManagementSystem.models.Product;

public class MainController implements Initializable {

//Entire Parts table
@FXML
private TableView<Part> MainPartsTable;

//Parts table ID column
@FXML
private TableColumn<Part, Integer> MainPartIDCol;

//Parts table Name column
@FXML
private TableColumn<Part, String> MainPartNameCol;

//Parts table Inventory column
@FXML
private TableColumn<Part, Integer> MainPartInStockCol;

//Parts table Price column
@FXML
private TableColumn<Part, Double> MainPartPriceCol;

//Part Search field
@FXML
private TextField MainPartsSearchField;

//Entire Products table
@FXML
private TableView<Product> MainProductsTable;

//Products table ID column
@FXML
private TableColumn<Product, Integer> MainProductIDCol;

//Products table Name column
@FXML
private TableColumn<Product, String> MainProductNameCol;

//Products table Inventory column
@FXML
private TableColumn<Product, Integer> MainProductInStockCol;

//Product table Price column
@FXML
private TableColumn<Product, Double> MainProductPriceCol;

//Product Search field
@FXML
private TextField MainProductsSearchField;

//The current modified Part
private static Part modifiedPart;

//The current modified Product
private static Product modifiedProduct;

//Constructor
public MainController() {
}

//Get Modified Part
public static Part getModifiedPart() {
return modifiedPart;
}

//Set Part as Modified
public void setModifiedPart(Part modifyPart) {
MainController.modifiedPart = modifyPart;
}

//Get Modified Product
public static Product getModifiedProduct() {
return modifiedProduct;
}

//Set Product as Modified
public void setModifiedProduct(Product modifiedProduct) {
MainController.modifiedProduct = modifiedProduct;
}

//Exit the Application
@FXML
void handleExit(ActionEvent event) {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.initModality(Modality.NONE);
alert.setTitle("Confirmation");
alert.setHeaderText("Confirm exit!");
alert.setContentText("Are you sure you want to exit?");
Optional<ButtonType> result = alert.showAndWait();

if (result.get() == ButtonType.OK) {
System.exit(0);
}
}

//Add a Part
@FXML
void handleAddPart(ActionEvent event) throws IOException {
showPartsScreen(event);
}

//Add a Product
@FXML
void handleAddProduct(ActionEvent event) throws IOException {
showProductScreen(event);
}

//Delete a Part
@FXML
void handleDeletePart(ActionEvent event) throws IOException {
Part part = MainPartsTable.getSelectionModel().getSelectedItem();

Alert alert = new Alert(AlertType.CONFIRMATION);
alert.initModality(Modality.NONE);
alert.setTitle("Part Delete");
alert.setHeaderText("Confirm deletion?");
alert.setContentText("Are you sure you want to delete " + part.getName() + "?");
Optional<ButtonType> result = alert.showAndWait();

if (result.get() == ButtonType.OK) {
deletePart(part.getId());
populatePartsTable();
}
}

//Delete a Product
@FXML
void handleDeleteProduct(ActionEvent event) throws IOException {
Product product = MainProductsTable.getSelectionModel().getSelectedItem();

Alert alert = new Alert(AlertType.CONFIRMATION);
alert.initModality(Modality.NONE);
alert.setTitle("Product Delete");
alert.setHeaderText("Confirm deletion?");
alert.setContentText("Are you sure you want to delete " + product.getName() + "?");
Optional<ButtonType> result = alert.showAndWait();

if (result.get() == ButtonType.OK) {
deleteProduct(product.getId());
populatePartsTable();

}
}

//Modify a Part
@FXML
void handleModifyPart(ActionEvent event) throws IOException {
modifiedPart = MainPartsTable.getSelectionModel().getSelectedItem();
setModifiedProduct(modifiedProduct);

showPartsScreen(event);
}

//Modify a Product
@FXML
void handleModifyProduct(ActionEvent event) throws IOException {
modifiedProduct = MainProductsTable.getSelectionModel().getSelectedItem();
setModifiedProduct(modifiedProduct);

showProductScreen(event);
}

//Search for a Part
@FXML
void handleSearchPart(ActionEvent event) throws IOException {
String partsSearchIdString = MainPartsSearchField.getText();
Part searchedPart = Inventory.lookupPart(Integer.parseInt(partsSearchIdString));

if (searchedPart != null) {
ObservableList<Part> filteredPartsList = FXCollections.observableArrayList();
filteredPartsList.add(searchedPart);
MainPartsTable.setItems(filteredPartsList);
} else {
populatePartsTable();
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Search Error");
alert.setHeaderText("Part not found");
alert.setContentText("The search term entered does not match any part!");
alert.showAndWait();
}
}

//Search for a Product
@FXML
void handleSearchProduct(ActionEvent event) throws IOException {
String productSearchIdString = MainProductsSearchField.getText();
Product searchedProduct = Inventory.lookupProduct(Integer.parseInt(productSearchIdString));

if (searchedProduct != null) {
ObservableList<Product> filteredProductList = FXCollections.observableArrayList();
filteredProductList.add(searchedProduct);
MainProductsTable.setItems(filteredProductList);
} else {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Search Error");
alert.setHeaderText("Product not found");
alert.setContentText("The search term entered does not match any current product in the inventory!");
alert.showAndWait();
}
}

//Initialize Part and Product with null values
@Override
public void initialize(URL url, ResourceBundle rb) {
setModifiedPart(null);
setModifiedProduct(null);

MainPartIDCol.setCellValueFactory(cellData -> new SimpleIntegerProperty(cellData.getValue().getId()).asObject());
MainPartNameCol.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().getName()));
MainPartInStockCol.setCellValueFactory(cellData -> new SimpleIntegerProperty(cellData.getValue().getStock()).asObject());
MainPartPriceCol.setCellValueFactory(cellData -> new SimpleDoubleProperty(cellData.getValue().getPrice()).asObject());

MainProductIDCol.setCellValueFactory(cellData -> new SimpleIntegerProperty(cellData.getValue().getId()).asObject());
MainProductNameCol.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().getName()));
MainProductInStockCol.setCellValueFactory(cellData -> new SimpleIntegerProperty(cellData.getValue().getStock()).asObject());
MainProductPriceCol.setCellValueFactory(cellData -> new SimpleDoubleProperty(cellData.getValue().getPrice()).asObject());

populatePartsTable();
populateProductsTable();
}

//Populates the Parts table.
public void populatePartsTable() {
MainPartsTable.setItems(getParts());
}

//Populates the Product table.
public void populateProductsTable() {
MainProductsTable.setItems(getProducts());
}

//Sets the main app, also Populates the Parts and Products tables.
public void setMainApp(ActionEvent event) {
populatePartsTable();
populateProductsTable();
}

//Display the Parts screen, used for both add and modify Parts functionality.
public void showPartsScreen(ActionEvent event) throws IOException {
Parent loader = FXMLLoader.load(getClass().getResource("Parts.fxml"));
Scene scene = new Scene(loader);
Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
window.setScene(scene);
window.show();
}

//Display the Products screen, used for both add and modify Products functionality.
public void showProductScreen(ActionEvent event) throws IOException {
Parent loader = FXMLLoader.load(getClass().getResource("Products.fxml"));
Scene scene = new Scene(loader);
Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
window.setScene(scene);
window.show();
}

//Display the Main screen, used for both add and modify Products functionality.
public void showMainScreen(ActionEvent event) throws IOException {
Parent loader = FXMLLoader.load(getClass().getResource("Main.fxml"));
Scene scene = new Scene(loader);
Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
window.setScene(scene);
window.show();
}
}

Source code for PartsController.java:

package InventoryManagementSystem.views;

import java.io.IOException;
import java.net.URL;
import java.util.Optional;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.stage.Modality;
import javafx.stage.Stage;

import InventoryManagementSystem.models.InHouse;
import InventoryManagementSystem.models.Inventory;
import InventoryManagementSystem.models.OutsourcePart;
import InventoryManagementSystem.models.Part;
import static InventoryManagementSystem.views.MainController.getModifiedPart;
import InventoryManagementSystem.exceptions.ValidationException;


public class PartsController implements Initializable {

//Part ID field
@FXML
private TextField PartsIDField;

//Part Name field
@FXML
private TextField PartsNameField;

//Part Inventory field
@FXML
private TextField PartsInStockField;

//Part Price field
@FXML
private TextField PartsPriceField;

//Part Maximum Inventory field
@FXML
private TextField PartsMaxField;

//Part Minimum Inventory field
@FXML
private TextField PartsMinField;

//Part Manufacturer/MachineID label
@FXML
private Label PartsMfgLabel;

//Part Manufacturer/MachineID field
@FXML
private TextField PartsMfgField;

//Part page label
@FXML
private Label PartsPageLabel;

//InHouse Part radio button
@FXML
private RadioButton PartsInHouseRadioButton;

//Outsourced Part radio button
@FXML
private RadioButton PartsOutsourcedRadioButton;

//Flag Part as InHouse vs. Outsourced
private boolean isInHouse;

//Part currently under modification
private final Part modifyPart;

//Constructor
public PartsController() {
this.modifyPart = getModifiedPart();
}

//Sets Part as one produced InHouse
@FXML
void handleInHouse(ActionEvent event) {
isInHouse = true;
PartsMfgLabel.setText("Mach ID");
}

//Sets Part as one produced by an Outsourced entity
@FXML
void handleOutsource(ActionEvent event) {
isInHouse = false;
PartsMfgLabel.setText("Company Nm");
}

//Cancel Part Modification
@FXML
void handleCancel(ActionEvent event) throws IOException {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.initModality(Modality.NONE);
alert.setTitle("Cancel Modification");
alert.setHeaderText("Confirm cancellation");
alert.setContentText("Are you sure you want to cancel update of part " + PartsNameField.getText() + "?");
Optional<ButtonType> result = alert.showAndWait();

if (result.get() == ButtonType.OK) {
Parent loader = FXMLLoader.load(getClass().getResource("Main.fxml"));
Scene scene = new Scene(loader);
Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
window.setScene(scene);
window.show();
}
}

//Save Part Modification
@FXML
void handleSave(ActionEvent event) throws IOException {
String partName = PartsNameField.getText();
String partInv = PartsInStockField.getText();
String partPrice = PartsPriceField.getText();
String partMin = PartsMinField.getText();
String partMax = PartsMaxField.getText();
String partDyn = PartsMfgField.getText();

if ("".equals(partInv)) {
partInv = "0";
}

if (isInHouse) {
InHouse modifiedPart = new InHouse();
modifiedPart.setName(partName);
modifiedPart.setPrice(Double.parseDouble(partPrice));
modifiedPart.setStock(Integer.parseInt(partInv));
modifiedPart.setMin(Integer.parseInt(partMin));
modifiedPart.setMax(Integer.parseInt(partMax));
modifiedPart.setMachineId(Integer.parseInt(partDyn));

try {
modifiedPart.isValid();
if (modifyPart == null) {
modifiedPart.setId(Inventory.getPartsCount());
Inventory.addPart(modifiedPart);
} else {
int partID = modifyPart.getId();
modifiedPart.setId(partID);
Inventory.updatePart(modifiedPart);
}

Parent loader = FXMLLoader.load(getClass().getResource("Main.fxml"));
Scene scene = new Scene(loader);
Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
window.setScene(scene);
window.show();
} catch (ValidationException e) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("ValidationError");
alert.setHeaderText("Part not valid");
alert.setContentText(e.getMessage());
alert.showAndWait();
}
} else {

OutsourcePart modifiedPart = new OutsourcePart();
modifiedPart.setName(partName);
modifiedPart.setPrice(Double.parseDouble(partPrice));
modifiedPart.setStock(Integer.parseInt(partInv));
modifiedPart.setMin(Integer.parseInt(partMin));
modifiedPart.setMax(Integer.parseInt(partMax));
modifiedPart.setCompanyName(partDyn);

try {
modifiedPart.isValid();

if (modifyPart == null) {
modifiedPart.setId(Inventory.getPartsCount());
Inventory.addPart(modifiedPart);
} else {
int partID = modifyPart.getId();
modifiedPart.setId(partID);
Inventory.updatePart(modifiedPart);
}

Parent loader = FXMLLoader.load(getClass().getResource("Main.fxml"));
Scene scene = new Scene(loader);
Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
window.setScene(scene);
window.show();
} catch (ValidationException e) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("ValidationError");
alert.setHeaderText("Part not valid");
alert.setContentText(e.getMessage());
alert.showAndWait();
}
}
}

//Initialize Part Data
@Override
public void initialize(URL url, ResourceBundle rb) {
if (modifyPart == null) {
PartsPageLabel.setText("Add Part");
int partAutoID = Inventory.getPartsCount();
PartsIDField.setText("AUTO GEN: " + partAutoID);

isInHouse = true;
PartsMfgLabel.setText("Mach ID");
} else {
PartsPageLabel.setText("Modify Part");
PartsIDField.setText(Integer.toString(modifyPart.getId()));
PartsNameField.setText(modifyPart.getName());
PartsInStockField.setText(Integer.toString(modifyPart.getStock()));
PartsPriceField.setText(Double.toString(modifyPart.getPrice()));
PartsMinField.setText(Integer.toString(modifyPart.getMin()));
PartsMaxField.setText(Integer.toString(modifyPart.getMax()));

if (modifyPart instanceof InHouse) {
PartsMfgField.setText(Integer.toString(((InHouse) modifyPart).getMachineId()));

PartsMfgLabel.setText("Mach ID");
PartsInHouseRadioButton.setSelected(true);

} else {
PartsMfgField.setText(((OutsourcePart) modifyPart).getCompanyName());
PartsMfgLabel.setText("Comp Nm");
PartsOutsourcedRadioButton.setSelected(true);
}
}
}
}

Source code for ProductsController.java:

package InventoryManagementSystem.views;

import java.io.IOException;
import java.net.URL;
import java.util.Optional;
import java.util.ResourceBundle;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.stage.Modality;
import javafx.stage.Stage;

import InventoryManagementSystem.models.Inventory;
import InventoryManagementSystem.models.Part;
import static InventoryManagementSystem.views.MainController.getModifiedProduct;
import InventoryManagementSystem.exceptions.ValidationException;
import InventoryManagementSystem.models.Product;

public class ProductsController implements Initializable {

//Product Page label
@FXML
private Label ProductsPageLabel;

//Product ID field
@FXML
private TextField ProductsIDField;

//Product Name field
@FXML
private TextField ProductsNameField;

//Product Maximum Inventory field
@FXML
private TextField ProductsMaxField;

//Product Minimum Inventory field
@FXML
private TextField ProductsMinField;

//Product Current Inventory field
@FXML
private TextField ProductsInStockField;

//Product Price field
@FXML
private TextField ProductsPriceField;

//Product's Parts Search field
@FXML
private TextField ProductPartsSearchField;

//Product's Parts table
@FXML
private TableView<Part> ProductAllPartsTable;

//Product's Parts table ID
@FXML
private TableColumn<Part, Integer> ProductAllPartsIDCol;

//Product's Parts table Name
@FXML
private TableColumn<Part, String> ProductAllPartsNameCol;

//Product's Parts table Inventory
@FXML
private TableColumn<Part, Integer> ProductAllPartsInStockCol;

//Product's Parts table Price
@FXML
private TableColumn<Part, Double> ProductAllPartsPriceCol;

//Product's Current Parts table
@FXML
private TableView<Part> ProductCurrentPartsTable;

//Product's Current Parts ID
@FXML
private TableColumn<Part, Integer> ProductCurrentPartsIDCol;

//Product's Current Parts Name
@FXML
private TableColumn<Part, String> ProductCurrentPartsNameCol;

//Product's Current Parts Inventory
@FXML
private TableColumn<Part, Integer> ProductCurrentPartsInStockCol;

//Product's Current Parts Price
@FXML
private TableColumn<Part, Double> ProductCurrentPartsPriceCol;

// Product's list of Parts associated with it
private ObservableList<Part> productParts = FXCollections.observableArrayList();

//Product currently under modification
private final Product modifiedProduct;

//Constructor
public ProductsController() {
this.modifiedProduct = getModifiedProduct();
}

//Add a Part to a Product
@FXML
void handleAddProductPart(ActionEvent event) {
Part part = ProductAllPartsTable.getSelectionModel().getSelectedItem();
productParts.add(part);
populateCurrentPartsTable();
populateAvailablePartsTable();
//Inventory.updateProduct(modifiedProduct);
}

//Cancel Product Modification
@FXML
void handleCancel(ActionEvent event) throws IOException {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.initModality(Modality.NONE);
alert.setTitle("Cancel Modification");
alert.setHeaderText("Confirm cancellation");
alert.setContentText("Are you sure you want to cancel update of product " + ProductsNameField.getText() + "?");
Optional<ButtonType> result = alert.showAndWait();

if (result.get() == ButtonType.OK) {
Parent loader = FXMLLoader.load(getClass().getResource("Main.fxml"));
Scene scene = new Scene(loader);
Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
window.setScene(scene);
window.show();
}
}

//Delete a Part from a Product
@FXML
void handleDeleteProductPart(ActionEvent event) throws IOException {
if (productParts.size() >= 2) {
Part part = ProductCurrentPartsTable.getSelectionModel().getSelectedItem();
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.initModality(Modality.NONE);
alert.setTitle("Delete Part");
alert.setHeaderText("Confirm deletion");
alert.setContentText("Are you sure you want to disassociate " + part.getName() + " ?");
Optional<ButtonType> result = alert.showAndWait();

if (result.get() == ButtonType.OK) {
productParts.remove(part);
}
} else {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Part Deletion Error!");
alert.setHeaderText("Product requires one part!");
alert.setContentText("This product must have at least one part.");
alert.showAndWait();
}
}

//Save Product Modification
@FXML
void handleProductSave(ActionEvent event) throws IOException {
String productId = ProductsIDField.getText();

String productName = ProductsNameField.getText();
String productPrice = ProductsPriceField.getText();
String productStock = ProductsInStockField.getText();
String productMin = ProductsMinField.getText();
String productMax = ProductsMaxField.getText();
Product newProduct = new Product();

// Verify New vs Modified Product
if (modifiedProduct != null) {
modifiedProduct.purgeAssociatedParts();
modifiedProduct.setId(Integer.parseInt(ProductsIDField.getText()));
modifiedProduct.setName(productName);
modifiedProduct.setPrice(Double.parseDouble(productPrice));
modifiedProduct.setStock(Integer.parseInt(productStock));
modifiedProduct.setMin(Integer.parseInt(productMin));
modifiedProduct.setMax(Integer.parseInt(productMax));
modifiedProduct.setId(modifiedProduct.getId());
for (Part p : productParts) {
modifiedProduct.addAssociatedPart(p);
}
Inventory.updateProduct(modifiedProduct);
try {
modifiedProduct.isValid();
Parent loader = FXMLLoader.load(getClass().getResource("Main.fxml"));
Scene scene = new Scene(loader);
Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
window.setScene(scene);
window.show();
} catch (ValidationException e) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("ValidationError");
alert.setHeaderText("Product not valid");
alert.setContentText(e.getMessage());
alert.showAndWait();
}
System.out.println("end of modified product");
} else {

productId = productId.substring(6);
newProduct.setId(Integer.parseInt(productId));
newProduct.setName(productName);
newProduct.setPrice(Double.parseDouble(productPrice));
newProduct.setStock(Integer.parseInt(productStock));
newProduct.setMin(Integer.parseInt(productMin));
newProduct.setMax(Integer.parseInt(productMax));
for (Part p : productParts) {
newProduct.addAssociatedPart(p);
}
Inventory.addProduct(newProduct);

try {
newProduct.isValid();
Parent loader = FXMLLoader.load(getClass().getResource("Main.fxml"));
Scene scene = new Scene(loader);
Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
window.setScene(scene);
window.show();
} catch (ValidationException e) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("ValidationError");
alert.setHeaderText("Product not valid");
alert.setContentText(e.getMessage());
alert.showAndWait();
}
}
}

//Search for Parts of a Product
@FXML
void handleSearchParts(ActionEvent event) throws IOException {
String partsSearchIdString = ProductPartsSearchField.getText();
Part searchedPart = Inventory.lookupPart(Integer.parseInt(partsSearchIdString));

if (searchedPart != null) {
ObservableList<Part> filteredPartsList = FXCollections.observableArrayList();
filteredPartsList.add(searchedPart);
ProductAllPartsTable.setItems(filteredPartsList);
} else {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Search Error");
alert.setHeaderText("Part not found");
alert.setContentText("The search term entered does not match any part!");
alert.showAndWait();

}
}

//Initialize
@Override
public void initialize(URL url, ResourceBundle rb) {
if (modifiedProduct == null) {
ProductsPageLabel.setText("Add Product");
int productAutoID = (Inventory.getProductsCount() + 1);
ProductsIDField.setText("Auto: " + productAutoID);
System.out.println("Here");
} else {
ProductsPageLabel.setText("Modify Product");

ProductsIDField.setText(Integer.toString(modifiedProduct.getId()));
ProductsNameField.setText(modifiedProduct.getName());
ProductsInStockField.setText(Integer.toString(modifiedProduct.getStock()));
ProductsPriceField.setText(Double.toString(modifiedProduct.getPrice()));
ProductsMinField.setText(Integer.toString(modifiedProduct.getMin()));
ProductsMaxField.setText(Integer.toString(modifiedProduct.getMax()));

productParts = modifiedProduct.getAllAssociatedParts();
}

ProductAllPartsIDCol.setCellValueFactory(cellData -> new SimpleIntegerProperty(cellData.getValue().getId()).asObject());
ProductAllPartsNameCol.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().getName()));
ProductAllPartsInStockCol.setCellValueFactory(cellData -> new SimpleIntegerProperty(cellData.getValue().getStock()).asObject());
ProductAllPartsPriceCol.setCellValueFactory(cellData -> new SimpleDoubleProperty(cellData.getValue().getPrice()).asObject());

ProductCurrentPartsIDCol.setCellValueFactory(cellData -> new SimpleIntegerProperty(cellData.getValue().getId()).asObject());
ProductCurrentPartsNameCol.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().getName()));
ProductCurrentPartsInStockCol.setCellValueFactory(cellData -> new SimpleIntegerProperty(cellData.getValue().getStock()).asObject());
ProductCurrentPartsPriceCol.setCellValueFactory(cellData -> new SimpleDoubleProperty(cellData.getValue().getPrice()).asObject());

populateAvailablePartsTable();
populateCurrentPartsTable();
}

//Populate the available parts table.
public void populateAvailablePartsTable() {
ProductAllPartsTable.setItems(Inventory.getParts());
}

//Populate the current parts table.
public void populateCurrentPartsTable() {
ProductCurrentPartsTable.setItems(productParts);
}

}
Source code for InventoryManagementSystem.java:

package InventoryManagementSystem;

import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import InventoryManagementSystem.models.InHouse;
import InventoryManagementSystem.models.OutsourcePart;
import InventoryManagementSystem.models.Inventory;
import InventoryManagementSystem.models.Part;
import InventoryManagementSystem.models.Product;

public class InventoryManagementSystem extends Application {

@Override
public void start(Stage stage) throws IOException {
Inventory inv = new Inventory();
addTestData(inv);

Parent root = FXMLLoader.load(getClass().getResource("/InventoryManagementSystem/views/Main.fxml"));

stage.setScene(new Scene(root));
stage.show();
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Application.launch(args);
}

public void addTestData(Inventory _inv) {
//Add InHouse Parts
//Part(int _id, String _name, double _price, int _stock, int _min, int _max){}; //constructor.
//public InHouse(int _id, String _name, double _price, int _stock, int _min, int _max, int _machineId)
Part a1 = new InHouse(1, "Part A1", 2.99, 10, 5, 100, 101);
Part a2 = new InHouse(3, "Part A2", 4.99, 11, 5, 100, 103);
Part b = new InHouse(2, "Part B", 3.99, 9, 5, 100, 102);
_inv.addPart(a1);
_inv.addPart(a2);
_inv.addPart(b);
_inv.addPart(new InHouse(4, "Part A3", 5.99, 15, 5, 100, 104));
_inv.addPart(new InHouse(5, "Part A4", 6.99, 5, 5, 100, 105));
//Add Outsourced Parts
//Part(int _id, String _name, double _price, int _stock, int _min, int _max){}; //constructor.
//public OutsourcePart(int _id, String _name, double _price, int _stock, int _min, int _max, String _companyName){
Part o1 = new OutsourcePart(6, "Part 01", 2.99, 10, 5, 100, "Acme Co.");
Part p = new OutsourcePart(7, "Part P", 3.99, 9, 5, 100, "Acme Co.");
Part q = new OutsourcePart(8, "Part Q", 2.99, 10, 5, 100, "Florida Co.");
_inv.addPart(o1);
_inv.addPart(p);
_inv.addPart(q);
_inv.addPart(new OutsourcePart(9, "Part R", 2.99, 10, 5, 100, "Florida Co."));
_inv.addPart(new OutsourcePart(10, "Part 02", 2.99, 10, 5, 100, "NY Co."));
//Add Products
//public Product(int _id, String _name, double _price, int _stock, int _min, int _max){}; //constructor
Product prod1 = new Product(1, "Product 1", 9.99, 20, 5, 100);
_inv.addProduct(prod1);
prod1.addAssociatedPart(a1);
prod1.addAssociatedPart(o1);
Product prod2 = new Product(2, "Product 2", 9.99, 22, 5, 100);
_inv.addProduct(prod2);
prod1.addAssociatedPart(a2);
prod1.addAssociatedPart(p);
Product prod3 = new Product(3, "Product 3", 9.99, 30, 5, 100);
_inv.addProduct(prod3);
prod1.addAssociatedPart(b);
prod1.addAssociatedPart(q);
_inv.addProduct(new Product(4, "Product 4", 29.99, 20, 5, 100));
_inv.addProduct(new Product(5, "Product 5", 29.99, 9, 5, 100));
}
}

I am not able upload fxml files here. So please go through this link and download all the files.

link: repl.it/repls/SpiffyUntimelyBooleanvalue

Output Screenshots:

X Inventory Management System Parts Search Search Parts by ID Products Search Search Products by IC Part ID Part Name Product

Hope it helps, if you like the answer give it a thumbs up. Thank you.

Add a comment
Know the answer?
Add Answer to:
I. User Interface Create a JavaFX application with a graphical user interface (GUI) based on the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need to make javafx GUI application called Email that implements a prototype user interface for...

    I need to make javafx GUI application called Email that implements a prototype user interface for composing email message. The application should have labelled text fields for To, cc,bcc ,subject line, one for message body and button lebelled Send. When we click Send button, the program should print contents of all fields to standard output using println() statement. I am attaching photos of Email.java and EmailPane.java, I need to make it as per these classes CylinderSta.. Cylinder java MultiCylind.. ....

  • JAVA Developing a graphical user interface in programming is paramount to being successful in the business...

    JAVA Developing a graphical user interface in programming is paramount to being successful in the business industry. This project incorporates GUI techniques with other tools that you have learned about in this class. Here is your assignment: You work for a flooring company. They have asked you to be a part of their team because they need a computer programmer, analyst, and designer to aid them in tracking customer orders. Your skills will be needed in creating a GUI program...

  • Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the...

    Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the motion of an object projected into the air at an angle. The object flies in the air until the projectile returns to the horizontal axis (x-axis), where y=0. This MATLAB program should allow the user to try to hit a 2-m diameter target on the x-axis (y=0) by varying conditions, including the lunch direction, the speed of the lunch, the projectile’s size, and the...

  • In this practice program you are going to practice creating graphical user interface controls and placing...

    In this practice program you are going to practice creating graphical user interface controls and placing them on a form. You are given a working NetBeans project shell to start that works with a given Invoice object that keeps track of a product name, quantity of the product to be ordered and the cost of each item. You will then create the necessary controls to extract the user input and display the results of the invoice. If you have any...

  • Question 1 (Marks: 50 Develop a Java GUI application that will produce an investment report based...

    Question 1 (Marks: 50 Develop a Java GUI application that will produce an investment report based on various criteria, such as investment amount, investment type and term. On the form create two text fields, one to capture the customer name and (10) Q.1.1 another to capture the amount to invest. Also create a combo box for the user to select the investment type which will be moderate or aggressive. Finally add three radio buttons for the user to select the...

  • C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) L...

    C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...

  • Modify the JavaFX TipCalculator application program to allow the user to enter the number of persons...

    Modify the JavaFX TipCalculator application program to allow the user to enter the number of persons in the party through a text field. Calculate and display the amount owed by each person in the party if the bill is to be split evenly among the party members. /////////// TipCalculatorController.java: import java.math.BigDecimal; import java.math.RoundingMode; import java.text.NumberFormat; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.control.Slider; import javafx.scene.control.TextField; public class TipCalculatorController { // formatters for currency and percentages private...

  • Question 2: Your task is to create a GUI application that allows a user to create a group of Hero objects s (think Lord of the Your group may be a small band of two or three Heroes or it may cons...

    Question 2: Your task is to create a GUI application that allows a user to create a group of Hero objects s (think Lord of the Your group may be a small band of two or three Heroes or it may consist of Rines or the Marvel Cinenatic Universe here) You have been given the compiled version of the dlass encapsulating a Hero and you have also been given the specification. Your job is to create a GUI application that...

  • I tried to complete a Java application that must include at a minimum: Three classes minimum...

    I tried to complete a Java application that must include at a minimum: Three classes minimum At least one class must use inheritance At least one class must be abstract JavaFX front end – as you will see, JavaFX will allow you to create a GUI user interface. The User Interface must respond to events. If your application requires a data backend, you can choose to use a database or to use text files. Error handling - The application should...

  • Lab 10: ArrayLists and Files in a GUI Application For this lab, you will work on...

    Lab 10: ArrayLists and Files in a GUI Application For this lab, you will work on a simple GUI application. The starting point for your work consists of four files (TextCollage, DrawTextItem, DrawTextPanel, and SimpleFileChooser) in the code directory. These files are supposed to be in package named "textcollage". Start an Eclipse project, create a package named textcollage in that project, and copy the four files into the package. To run the program, you should run the file TextCollage.java, which...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT