Question

In: Computer Science

I need a Java application with a GUI that includes the following requirements: Three classes minimum...

I need a Java application with a GUI that includes the following requirements:

  • Three classes minimum
  • At least one class must use inheritance
  • At least one class must be abstract
  • Utilization of “get set” method. (get; set; =  is related to how variables are passed between different classes. The get method is used to obtain or retrieve a particular variable value from a class. A set value is used to store the variables. The whole point of the get and set is to retrieve and store the data values accordingly). See below for example of the get set method. V V V V V V V V V V V V V V V
  • toString method
  • polymorphism
  • 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 the application requires a data backend, you can choose to use a database or to use text files. I would prefer text files.
  • Error handling - The application should be able to handle invalid data.

I was thinking of something with an ordering system for a restaurant, or something with a school, students, instructors, ID’s, grades, and GPA’s.  

The deliverables needed will be the code and GUI, along with a UML that shows the classes.

Example of get; set; method.

{
abstract class Photo
{
public double Height { get; set; }
public double Width { get; set; }

public double Price { get; set; }

public abstract void DisplayPhotoInfo();

}
}

Solutions

Expert Solution

There are a total of 6 Files:-

Model Classes:-

1.Food.java

2.Drinks.java

Abstract Class

3.Price.java

Controller File

4.FXMLDocumentController.java

FXML frontend FXML File

5.FXMLDocument.fxml

.Main File

6.MyRestaurantFX.java

Below are the codes of the above files:-

1.Food.java


package myrestaurantfx;
public class Food extends Price{
  
private String foodName;

public String getFoodName() {
return foodName;
}

public void setFoodName(String foodName) {
this.foodName = foodName;
}

public float getPrice() {
return price;
}

public void setPrice(float price) {
this.price = price;
}
   
}


2.Drinks.java


package myrestaurantfx;
public class Drinks extends Price{
  
private String drinksName;

public String getDrinksName() {
return drinksName;
}

public void setDrinksName(String drinksName) {
this.drinksName = drinksName;
}

public float getPrice() {
return price;
}

public void setPrice(float price) {
this.price = price;
}
  
}

3.Price.java


package myrestaurantfx;
public class Drinks extends Price{
  
private String drinksName;

public String getDrinksName() {
return drinksName;
}

public void setDrinksName(String drinksName) {
this.drinksName = drinksName;
}

public float getPrice() {
return price;
}

public void setPrice(float price) {
this.price = price;
}
  
}

4.FXMLDocumentController.java


package myrestaurantfx;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;


public class FXMLDocumentController implements Initializable {
  
  
// Linking textfields, buttons and textarea with frontend
  
@FXML
private Label label;
  
@FXML
TextField foodTF,drinksTF;
  
@FXML
Button orderFoodBtn,orderDrinksBtn;
  
@FXML
TextArea orderTextArea;
  
  
  
@Override
public void initialize(URL url, ResourceBundle rb) {

}
  
  
@FXML
public void orderFood(ActionEvent ev)
{
Food food=new Food();
String foodName=foodTF.getText();
food.setFoodName(foodName);
ordersPlaced(food);
System.out.print("orderDrink");
  
}

@FXML
public void orderDrinks(ActionEvent ev)
{
Drinks drinks=new Drinks();
String drinksName=drinksTF.getText();
drinks.setDrinksName(drinksName);
ordersPlaced(drinks);
System.out.print("orderDrink");
}


public void ordersPlaced(Object item)
{
String items="";

if(item instanceof Food)
{
items=((Food) item).getFoodName();
}
else if(item instanceof Drinks)
{
items=((Drinks) item).getDrinksName();

}

orderTextArea.setText(orderTextArea.getText()+"\n"+"Your order of "+ items +" is placed"+ "\n");


}
  
  
}

5.FXMLDocument.fxml

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>


<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="myrestaurantfx.FXMLDocumentController">
<children>
<Label layoutX="218.0" layoutY="36.0" prefHeight="17.0" prefWidth="109.0" style="-fx-background-color: #9ef59d;" text="MY RESTAURANT" textAlignment="RIGHT" />
<Label layoutX="115.0" layoutY="86.0" style="-fx-background-color: #f5bc42;" text="FOOD" />
<Label layoutX="355.0" layoutY="86.0" style="-fx-background-color: #f5bc42;" text="DRINKS" />
<TextField fx:id="foodTF" layoutX="74.0" layoutY="121.0" />
<TextField fx:id="drinksTF" layoutX="316.0" layoutY="121.0" />
<Button fx:id="orderFoodBtn" layoutX="98.0" layoutY="167.0" mnemonicParsing="false" onAction="#orderFood" prefHeight="25.0" prefWidth="102.0" style="-fx-background-color: #9dd4f5;" text="ORDER FOOD" />
<Button fx:id="orderDrinksBtn" layoutX="346.0" layoutY="167.0" mnemonicParsing="false" onAction="#orderDrinks" prefHeight="25.0" prefWidth="109.0" style="-fx-background-color: #9dd4f5;" text="ORDER DRINKS" />
<TextArea fx:id="orderTextArea" layoutX="88.0" layoutY="251.0" prefHeight="102.0" prefWidth="368.0" />
<Label layoutX="206.0" layoutY="219.0" prefHeight="17.0" prefWidth="109.0" style="-fx-background-color: #d89df5;" text="YOUR ORDERS" />
<Label layoutX="75.0" layoutY="103.0" prefHeight="17.0" prefWidth="135.0" style="-fx-background-color: #42f5ce;" text="Bread | Omlette | Chicken" />
<Label layoutX="323.0" layoutY="103.0" prefHeight="17.0" prefWidth="135.0" style="-fx-background-color: #42f5ce;" text="Coke| Whiskey| Wine" />
</children>
</AnchorPane>

MyRestaurantFX .java


package myrestaurantfx;

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

public class MyRestaurantFX extends Application {
  
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
  
Scene scene = new Scene(root);
stage.setTitle("MyRestaurant JavaFx Project");
stage.setScene(scene);
stage.show();
}

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

Package Structure:

GUI screen

UML Diagram:


The Project is written in Netbeans IDE using Gluon SceneBuilder.


Related Solutions

I need a full java code. And I need it in GUI With the mathematics you...
I need a full java code. And I need it in GUI With the mathematics you have studied so far in your education you have worked with polynomials. Polynomials are used to describe curves of various types; people use them in the real world to graph curves. For example, roller coaster designers may use polynomials to describe the curves in their rides. Polynomials appear in many areas of mathematics and science. Write a program which finds an approximate solution to...
Create a java Swing GUI application that presents the user with a “fortune”. Create a java...
Create a java Swing GUI application that presents the user with a “fortune”. Create a java Swing GUI application in a new Netbeans project called FortuneTeller. Your project will have a FortuneTellerFrame.java class (which inherits from JFrame) and a java main class: FortuneTellerViewer.java. Your application should have and use the following components: Top panel: A JLabel with text “Fortune Teller” (or something similar!) and an ImageIcon. Find an appropriate non-commercial Fortune Teller image for your ImageIcon. (The JLabel has a...
This is in Java 1. Create an application called registrar that has the following classes: a....
This is in Java 1. Create an application called registrar that has the following classes: a. A student class that minimally stores the following data fields for a student:  Name  Student id number  Number of credits  Total grade points earned             And this class should also be provides the following methods:  A constructor that initializes the name and id fields  A method that returns the student name field  A method that returns the student...
Java programming. *******I Need complete the following requirements in this project: 1/ Remove the applyRandomBonus method...
Java programming. *******I Need complete the following requirements in this project: 1/ Remove the applyRandomBonus method from the test class 2/ Create a File, Printwriter for an output file yourlastnameErrorLog.txt 3/ Set your maximum array size for accounts to 10 4/ Catch InputMismatch and ArrayIndexOutOfBounds exceptions when reading data from the file: a. Skip any lines that cause an exception b. Write information about the exception to the log file, yourlastnameError.txt c. Include exception type and line number in exception...
Create in java an interactive GUI application program that will prompt the user to use one...
Create in java an interactive GUI application program that will prompt the user to use one of three calculators, label project name MEDCALC. You can use any color you want for your background other than grey. Be sure to label main java box with “MEDCALC” and include text of “For use only by students” On all three calculators create an alert and signature area for each user. The alert should be something like “All calculations must be confirmed by user...
Java Programming I need an application that collects the user input numbers into an array and...
Java Programming I need an application that collects the user input numbers into an array and after that calls a method that sums all the elements of this array. and display the array elements and the total to the user. The user decides when to stop inputting the numbers. Thanks for your help!
In this question, use your new GUI classes to create a small application. You have 2...
In this question, use your new GUI classes to create a small application. You have 2 options: Write any small application of your choice, as long as it follows the rules that follow. Write the small UnitConversion application, which will be described for you. Option 1: Write your own application You can write any small application that you like, as long as: It uses your GUI classes, including: at least one checkbox, at least one group of 3 radio buttons,...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of...
Write an application and perform the following:(NO USER INPUT) -Create at least three classes such as:...
Write an application and perform the following:(NO USER INPUT) -Create at least three classes such as: 1. listnode- for data and link, constructors 2. Singlelinkedlist-for method definition 3. linkedlist-for objects -Insert a node at tail/end in a linked list. -and display all the nodes in the list. -Delete a node at a position in the list Note: Add these methods in the same application which we have done in the class. this is what we've done in the class: class...
Using a minimum of 2 classes create a java program that writes data to a file...
Using a minimum of 2 classes create a java program that writes data to a file when stopped and reads data from a file when started. The data should be in a readable format and the program should work in a way that stopping and starting is irrelevant (e.g. all data doesn't have to save just the important elements.) Program should be unique and semi-complex in some way.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT