The document describes a Java program that implements a linked list of Car objects. It includes classes for the Car object with attributes like make, model, year, and color, and a NuLinkedList class that implements basic linked list functionality for adding, removing, and accessing Car elements. The program reads a file of cars into an ArrayList and provides buttons to navigate between cars, displaying the current car details. The request is to add delete and add buttons to allow removing and adding cars to the linked list from the GUI.
Measures of Central Tendency: Mean, Median and Mode
can you add a delete button and a add button to the below program. j.pdf
1. can you add a delete button and a add button to the below program. java fx
package nusoft;
public class Car {
private String make;
private String model;
private int year;
private String color;
public Car(String make, int year, String model, String color) {
this.make = make;
this.model = model;
this.year = year;
this.color = color;
}
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public int getYear() {
return year;
}
2. public void setYear(int year) {
this.year = year;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
@Override
public String toString() {
return year + " " + make + " " + model + " (" + color + ")";
}
}
package nusoft;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class CarNavigator extends Application {
private ArrayList cars = new ArrayList<>();
private int currentIndex = 0;
@Override
3. public void start(Stage primaryStage) throws Exception {
readCarsFile();
Label carLabel = new Label();
carLabel.setAlignment(Pos.CENTER);
updateCarLabel(carLabel);
Button prevButton = new Button("Previous");
prevButton.setOnAction(e -> {
currentIndex--;
if (currentIndex < 0) {
currentIndex = cars.size() - 1;
}
updateCarLabel(carLabel);
});
Button nextButton = new Button("Next");
nextButton.setOnAction(e -> {
currentIndex++;
if (currentIndex >= cars.size()) {
currentIndex = 0;
}
updateCarLabel(carLabel);
});
VBox buttonBox = new VBox(10, prevButton, nextButton);
buttonBox.setAlignment(Pos.CENTER);
BorderPane root = new BorderPane(carLabel, null, null, buttonBox, null);
Scene scene = new Scene(root, 400, 200);
primaryStage.setScene(scene);
primaryStage.show();
}
private void readCarsFile() throws IOException {