Question
Please add an abstract class and interface to this java program . Main.java //Imports: import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.geometry.Insets; import javafx.scene.Scene; import
Please add an abstract class and interface to this java program .
Main.java
//Imports: import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.TextField; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.stage.Stage;
//Application Class public class Main extends Application {
Stage window; TableView
public static void main(String[] args) { launch(args); }
@Override public void start(Stage primaryStage) throws Exception { window = primaryStage; window.setTitle("JoeyWhitmore - JavaFX");
//Name column TableColumn
//Price column TableColumn
//Quantity column TableColumn
//Name input nameInput = new TextField(); nameInput.setPromptText("Name"); nameInput.setMinWidth(100);
//Price input priceInput = new TextField(); priceInput.setPromptText("Price");
//Quantity input quantityInput = new TextField(); quantityInput.setPromptText("Quantity");
//Button Button addButton = new Button("Add"); addButton.setOnAction(e -> addButtonClicked()); Button deleteButton = new Button("Delete"); deleteButton.setOnAction(e -> deleteButtonClicked());
HBox hBox = new HBox(); hBox.setPadding(new Insets(10,10,10,10)); hBox.setSpacing(10); hBox.getChildren().addAll(nameInput, priceInput, quantityInput, addButton, deleteButton);
table = new TableView<>(); table.setItems(getProduct()); table.getColumns().addAll(nameColumn, priceColumn, quantityColumn);
VBox vBox = new VBox(); vBox.getChildren().addAll(table, hBox);
Scene scene = new Scene(vBox); window.setScene(scene); window.show(); }
//Add button clicked public void addButtonClicked(){ Product product = new Product(); product.setName(nameInput.getText()); product.setPrice(Double.parseDouble(priceInput.getText())); product.setQuantity(Integer.parseInt(quantityInput.getText())); table.getItems().add(product); nameInput.clear(); priceInput.clear(); quantityInput.clear(); }
//Delete button clicked public void deleteButtonClicked(){ ObservableList
productSelected.forEach(allProducts::remove); }
//Get all of the products public ObservableList
}
Product.java
public class Product {
private String name; private double price; private int quantity;
public Product(){ this.name = ""; this.price = 0; this.quantity = 0; }
public Product(String name, double price, int quantity){ this.name = name; this.price = price; this.quantity = quantity; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public double getPrice() { return price; }
public void setPrice(double price) { this.price = price; }
public int getQuantity() { return quantity; }
public void setQuantity(int quantity) { this.quantity = quantity; }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started