Download the project named inlab3-spr21-given.zip from the course website and import it as an "Existing Eclipse project" into your workspace. The packages in this project are shown in Figure 1. Run the EmploveeApp to make sure that your project works correctly. You should get a blank GUI. Your task is to fill this GUI with components, as described below. Note that the EmploveeView and the EmploveeController are empty. You should develop them as detailed below. All other classes are fully implemented and you should not edit them.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

You need edit EmployeeView and EmployeeController classes only.

Use SceneBuilder toopen the EmployeeView.fxml

Question is down below: Please do it

Classes:

EmployeeController class:

 

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;

public class EmployeeController {

@FXML
private Label NameEM;

@FXML
private Label MakerEM;

@FXML
private Label PriceEM;

@FXML
private Button handlehascar;

@FXML
private Button AddButton;

@FXML
private TextArea TextAreaBox;


}

 

EmployeeApp Class:

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.Pane;
import javafx.scene.Scene;
import javafx.stage.Modality;
import javafx.stage.Stage;

public class EmployeeApp extends Application {

@Override
public void start(Stage stage) throws Exception{
Pane root = FXMLLoader.load(getClass().getResource("/view/EmployeeView.fxml"));
stage.setScene(new Scene(root));
stage.setTitle("Employee App");
stage.show();
}

public static void main(String[] args) {
launch(args);
}
}

EmployeeController class:

package controller;

public class EmployeeController {


}

Automobile Class:

package model;

public class Automobile {
private String maker;
private double price;
private double mileage;
private static int count;

public Automobile(String maker, double price) {
this.maker = maker;
setPrice(price);
this.mileage=400000-0.7*this.price;//mileage inversely proportional to the price.
count++;
}

public String getMaker() {
return maker;
}

public void setMaker(String maker) {
this.maker = maker;
}

public void move(double averageSpeed, double hours){
double drivenMiles=hours*averageSpeed;
this.mileage += drivenMiles;
if(this.price-0.25*drivenMiles > 4500)
this.price -= 0.25*drivenMiles;
}

public double getMileage() {
return mileage;
}

public double getPrice() {
return price;
}

public void setPrice(double price) {
this.price = (price > 4600 && price <= 349000)? price: 4600;
}

public static int getCount() {
return count;
}

public String getCondition() {
if (price < 16000)
return "Poor";
else if (price < 75000)
return "Good";
else
return "Excellent";
}

public String toString() {
return String.format("Make: %-10s Mileage: %,.1f km Price: QR%,.0f Condition: %-12s",
maker, mileage, price, getCondition());
}
}

Employee Class:

package model;

public class Employee {
private String name;
private Automobile vehicle;

public Employee(String name, Automobile vehicle) {
this.name = name;
this.vehicle = vehicle;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Automobile getVehicle() {
return vehicle;
}

public void setVehicle(Automobile vehicle) {
this.vehicle = vehicle;
}

public boolean hasVehicle() {
return vehicle!=null;
}
public String toString() {
String str = String.format("Name: %s\n", name);
if(hasVehicle())
str+="Vehicle details:\n"+vehicle;
return str;
}
}

EmployeeRepo Class:

package repository;

import java.util.ArrayList;
import java.util.List;

import model.Automobile;
import model.Employee;

public class EmployeeRepo {

private static List<Employee> employees = new ArrayList<>();

public static List<Employee> getEmployees() {
return employees;
}

public static void addEmployee(Employee emp) {
if (emp != null)
employees.add(emp);
}
public static void initializeList() {
addEmployee(new Employee("Ahmed Taha", null));
addEmployee(new Employee("Nasri Khalifa", new Automobile("Ford", 2340)));
addEmployee(new Employee("Mohamed Othman", new Automobile("Nissan", 47500)));
addEmployee(new Employee("Hanan Ali", null));
addEmployee(new Employee("Khalid Ahmed", null));
addEmployee(new Employee("Suad Fahad", new Automobile("Ford", 67300)));
addEmployee(new Employee("Abdalla Ibrahim", new Automobile("Toyota", 54000)));
addEmployee(new Employee("Sulaiman Abdo", new Automobile("Toyota", 307500)));
addEmployee(new Employee("Sayed Khalifa", new Automobile("Chevy", 25750)));
addEmployee(new Employee("Sara Mansoor", new Automobile("Chevy", 36980)));
addEmployee(new Employee("Saad Khamis", new Automobile("Mercedes", 68500)));
}
}

EmployeeView.fxml

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

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ToolBar?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>


<VBox alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controller.EmployeeController">

</VBox>

 

 

Download the project named inlab3-spr21-given.zip from the course
website and import it as an "Existing Eclipse project" into your workspace.
The packages in this project are shown in Figure 1. Run the EmploxeeApR
to make sure that your project works correctly. You should get a blank GUI.
Your task is to fill this GUI with components, as described below.
v inlab3-spr21-given
v src
v B app
>D EmployeeAppjava
v # controller
v D EmployeeController.java
© EmployeeController
Note that the EmploveeView and the EmploveeController are empty. You
should develop them as detailed below. All other classes are fully
implemented and you should not edit them.
- # model
> A Automobilejava
> D Employee.java
> # repository
v B view
O EmployeeView.fxml
a JRE System Library ljre)
Requirements:
a JavaFX
1. Using SceneBuilder, open the EmrlexeeView and create
Employee Data Entry, similar to the form shown in Figure 2. The
TextArea is to be filled by the current employee list after adding a
new employee. To help you, the component tree is also shown on the figure:
form for
Figure 1: Packages and source files
O EmplayeeView.femi
File Edit View insert
Modify Arrange Preview Window Help
Library
No Selection
Containers
Controk
Employee Data Entry
Cluan
Manu
Name
Miscalanaous
Has a Car?
Shapes
Car maker
Charts
30
Price
Document
Hierarchy
Add
Clear Exit
O E Vax
List of Employees
A Label Employee Data Entry
E GridPane (2 x4)
O Label (0, 0) Name
O Label (0, 2) Car maker
O Label (0, 3) Price
O TextField (1, O
O TextField (1, 2)
O TextField (1, 3)
O Button (1, 1) Has a Car?
O D ToolBar
O Button Add
O Button Clear
O Button Eait
A Label List of Emplovees
O TextArea
Controller
Figure 2: Employes View
1
2. When the form is loaded by the EmploveeApp, it should initially hide the car maker and Price
labels and textfields, as shown in Figure 3. It should also initialize the employees list (Hint: by
calling a method in EmploxeeReno). When the "Has a Car?" button is clicked, the form displays as
in Figure 4.
tmployee App
tmoloyee App
Employee Data Entry
Employee Data Entry
Name
Name
Has a Car
Has a Car?
Car maker
Price
Add Clear Et
Add Clear Exit
List of Employees
List of Employees
Figure 3: Employee without a car
Figure 4: Employvee has a car
Emgloyee App
3. When the user fills the required data and clicks
the "Add" button, an Employee instance should
be created and added to the employees list
(Hint: use the static addEmoloveel) method in
the EmploxeeRere). The employees list should
then be displayed in the TextArea in the GUI.
(Notice the added data are highlighted record in
Employee Data Entry
Name
Sayed Eayed
Has a Car?
Car maker
Chew
Price
40000
Add Clear Exit
Figure 5)
List of Employees
Name Sulaman Ade
Vehicle detait
Make Toyota Milesge 184,7500 km Price ORJ07.500 Con
I
Name: Sayed Khalifa
Vehicle detaik
Make Chevy Mileage: 381975.0 km Price: OR25,7s0 Condi
s:
Name: Sara Manson
Vetice deta
Make Chevy Mieage 274,1140 km Price OR 0 Conti
Name: Saad Khamis
Vehicle detait:
Make Mercedes Mleaor: 3520s0.0 km Price: oS s00 Con
Name Sayed
Vehicle detail
Make Chevy Mieage 0000 km Price ORA000 Cond
Figure 5: A new Employee Added
Transcribed Image Text:Download the project named inlab3-spr21-given.zip from the course website and import it as an "Existing Eclipse project" into your workspace. The packages in this project are shown in Figure 1. Run the EmploxeeApR to make sure that your project works correctly. You should get a blank GUI. Your task is to fill this GUI with components, as described below. v inlab3-spr21-given v src v B app >D EmployeeAppjava v # controller v D EmployeeController.java © EmployeeController Note that the EmploveeView and the EmploveeController are empty. You should develop them as detailed below. All other classes are fully implemented and you should not edit them. - # model > A Automobilejava > D Employee.java > # repository v B view O EmployeeView.fxml a JRE System Library ljre) Requirements: a JavaFX 1. Using SceneBuilder, open the EmrlexeeView and create Employee Data Entry, similar to the form shown in Figure 2. The TextArea is to be filled by the current employee list after adding a new employee. To help you, the component tree is also shown on the figure: form for Figure 1: Packages and source files O EmplayeeView.femi File Edit View insert Modify Arrange Preview Window Help Library No Selection Containers Controk Employee Data Entry Cluan Manu Name Miscalanaous Has a Car? Shapes Car maker Charts 30 Price Document Hierarchy Add Clear Exit O E Vax List of Employees A Label Employee Data Entry E GridPane (2 x4) O Label (0, 0) Name O Label (0, 2) Car maker O Label (0, 3) Price O TextField (1, O O TextField (1, 2) O TextField (1, 3) O Button (1, 1) Has a Car? O D ToolBar O Button Add O Button Clear O Button Eait A Label List of Emplovees O TextArea Controller Figure 2: Employes View 1 2. When the form is loaded by the EmploveeApp, it should initially hide the car maker and Price labels and textfields, as shown in Figure 3. It should also initialize the employees list (Hint: by calling a method in EmploxeeReno). When the "Has a Car?" button is clicked, the form displays as in Figure 4. tmployee App tmoloyee App Employee Data Entry Employee Data Entry Name Name Has a Car Has a Car? Car maker Price Add Clear Et Add Clear Exit List of Employees List of Employees Figure 3: Employee without a car Figure 4: Employvee has a car Emgloyee App 3. When the user fills the required data and clicks the "Add" button, an Employee instance should be created and added to the employees list (Hint: use the static addEmoloveel) method in the EmploxeeRere). The employees list should then be displayed in the TextArea in the GUI. (Notice the added data are highlighted record in Employee Data Entry Name Sayed Eayed Has a Car? Car maker Chew Price 40000 Add Clear Exit Figure 5) List of Employees Name Sulaman Ade Vehicle detait Make Toyota Milesge 184,7500 km Price ORJ07.500 Con I Name: Sayed Khalifa Vehicle detaik Make Chevy Mileage: 381975.0 km Price: OR25,7s0 Condi s: Name: Sara Manson Vetice deta Make Chevy Mieage 274,1140 km Price OR 0 Conti Name: Saad Khamis Vehicle detait: Make Mercedes Mleaor: 3520s0.0 km Price: oS s00 Con Name Sayed Vehicle detail Make Chevy Mieage 0000 km Price ORA000 Cond Figure 5: A new Employee Added
Expert Solution
steps

Step by step

Solved in 3 steps with 10 images

Blurred answer
Knowledge Booster
JQuery and Javascript
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education