SlideShare a Scribd company logo
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;
}
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
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 {
BufferedReader reader = new BufferedReader(new FileReader("cars.txt"));
String line;
while ((line = reader.readLine()) != null) {
cars.add(line);
}
reader.close();
}
private void updateCarLabel(Label label) {
label.setText(cars.get(currentIndex));
}
public static void main(String[] args) {
launch(args);
}
}
package nusoft.utils;
import java.util.NoSuchElementException;
import nusoft.Car;
public class NuLinkedList {
private Node head;
private Node tail;
private int size;
private static class Node {
E element;
Node prev;
Node next;
Node(E element, Node prev, Node next) {
this.element = element;
this.prev = prev;
this.next = next;
}
}
public boolean contains(E e) {
return indexOf(e) != -1;
}
public E get(int index) {
if (index < 0 || index >= size) {
throw new IndexOutOfBoundsException();
}
return getNode(index).element;
}
public int indexOf(E e) {
int index = 0;
for (Node node = head; node != null; node = node.next) {
if (e == null ? node.element == null : e.equals(node.element)) {
return index;
}
index++;
}
return -1;
}
public int lastIndexOf(E e) {
int index = size - 1;
for (Node node = tail; node != null; node = node.prev) {
if (e == null ? node.element == null : e.equals(node.element)) {
return index;
}
index--;
}
return -1;
}
public E set(int index, E e) {
if (index < 0 || index >= size) {
throw new IndexOutOfBoundsException();
}
Node node = getNode(index);
E oldElement = node.element;
node.element = e;
return oldElement;
}
public void add(E e) {
addLast(e);
}
public void add(int index, E e) {
if (index < 0 || index > size) {
throw new IndexOutOfBoundsException();
}
if (index == size) {
addLast(e);
} else {
addBefore(getNode(index), e);
}
}
public void addFirst(E e) {
if (size == 0) {
head = tail = new Node<>(e, null, null);
} else {
head.prev = new Node<>(e, null, head);
head = head.prev;
}
size++;
}
public void addLast(E e) {
if (size == 0) {
head = tail = new Node<>(e, null, null);
} else {
tail.next = new Node<>(e, tail, null);
tail = tail.next;
}
size++;
}
public E remove(int index) {
if (index < 0 || index >= size) {
throw new IndexOutOfBoundsException();
}
return remove(getNode(index));
}
public E removeFirst() {
if (size == 0) {
throw new NoSuchElementException();
}
return remove(head);
}
public E removeLast() {
if (size == 0) {
throw new NoSuchElementException();
}
return remove(tail);
}
public int size() {
return size;
}
private Node getNode(int index) {
if (index < size / 2) {
Node node = head;
for (int i = 0;i < index; i++) {
node = node.next;
}
return node;
} else {
Node node = tail;
for (int i = size - 1; i > index; i--) {
node = node.prev;
}
return node;
}
}
private void addBefore(Node node, E e) {
Node newNode = new Node<>(e, node.prev, node);
node.prev.next = newNode;
node.prev = newNode;
size++;
}
private E remove(Node node) {
if (node == head) {
head = node.next;
} else {
node.prev.next = node.next;
}
if (node == tail) {
tail = node.prev;
} else {
node.next.prev = node.prev;
}
size--;
return node.element;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[");
for (Node node = head; node != null; node = node.next) {
if (node != head) {
sb.append(", ");
}
sb.append(node.element);
}
sb.append("]");
return sb.toString();
}
public void remove(Car lastCar) {
// TODO Auto-generated method stub
}
}
( import java. io. BufferedReader;

More Related Content

Similar to can you add a delete button and a add button to the below program. j.pdf (20)

For the following questions, you will implement the data structure to.pdf
For the following questions, you will implement the data structure to.pdfFor the following questions, you will implement the data structure to.pdf
For the following questions, you will implement the data structure to.pdf
arjunhassan8
 
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdfImplement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
rishabjain5053
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdf
annaelctronics
 
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
rozakashif85
 
package ex2- public class Exercise2-E- { private static class N.pdf
package ex2- public class Exercise2-E- {        private static class N.pdfpackage ex2- public class Exercise2-E- {        private static class N.pdf
package ex2- public class Exercise2-E- { private static class N.pdf
arcellzone
 
Submit1) Java Files2) Doc file with the following contents.pdf
Submit1) Java Files2) Doc file with the following contents.pdfSubmit1) Java Files2) Doc file with the following contents.pdf
Submit1) Java Files2) Doc file with the following contents.pdf
akaluza07
 
import java.util.Iterator; import java.util.NoSuchElementException; .pdf
  import java.util.Iterator; import java.util.NoSuchElementException; .pdf  import java.util.Iterator; import java.util.NoSuchElementException; .pdf
import java.util.Iterator; import java.util.NoSuchElementException; .pdf
deepakangel
 
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdfThis is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
bharatchawla141
 
Note- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docxNote- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docx
VictorzH8Bondx
 
So I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfSo I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdf
aksahnan
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
arrowmobile
 
Note- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdfNote- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdf
Stewart29UReesa
 
Use the singly linked list class introduced in the lab to implement .pdf
Use the singly linked list class introduced in the lab to implement .pdfUse the singly linked list class introduced in the lab to implement .pdf
Use the singly linked list class introduced in the lab to implement .pdf
sales87
 
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdfLab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
QalandarBux2
 
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdf
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdfCopy your completed LinkedList class from Lab 3 into the LinkedList..pdf
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdf
facevenky
 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdf
contact41
 
Create a new java class called ListNode. Implement ListNode as a gen.pdf
Create a new java class called ListNode. Implement ListNode as a gen.pdfCreate a new java class called ListNode. Implement ListNode as a gen.pdf
Create a new java class called ListNode. Implement ListNode as a gen.pdf
mohamednihalshahru
 
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdfClass DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
xlynettalampleyxc
 
Note             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfNote             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdf
Ankitchhabra28
 
hi i have to write a java program involving link lists. i have a pro.pdf
hi i have to write a java program involving link lists. i have a pro.pdfhi i have to write a java program involving link lists. i have a pro.pdf
hi i have to write a java program involving link lists. i have a pro.pdf
archgeetsenterprises
 
For the following questions, you will implement the data structure to.pdf
For the following questions, you will implement the data structure to.pdfFor the following questions, you will implement the data structure to.pdf
For the following questions, you will implement the data structure to.pdf
arjunhassan8
 
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdfImplement the interface you wrote for Lab B (EntryWayListInterface)..pdf
Implement the interface you wrote for Lab B (EntryWayListInterface)..pdf
rishabjain5053
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdf
annaelctronics
 
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
rozakashif85
 
package ex2- public class Exercise2-E- { private static class N.pdf
package ex2- public class Exercise2-E- {        private static class N.pdfpackage ex2- public class Exercise2-E- {        private static class N.pdf
package ex2- public class Exercise2-E- { private static class N.pdf
arcellzone
 
Submit1) Java Files2) Doc file with the following contents.pdf
Submit1) Java Files2) Doc file with the following contents.pdfSubmit1) Java Files2) Doc file with the following contents.pdf
Submit1) Java Files2) Doc file with the following contents.pdf
akaluza07
 
import java.util.Iterator; import java.util.NoSuchElementException; .pdf
  import java.util.Iterator; import java.util.NoSuchElementException; .pdf  import java.util.Iterator; import java.util.NoSuchElementException; .pdf
import java.util.Iterator; import java.util.NoSuchElementException; .pdf
deepakangel
 
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdfThis is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
bharatchawla141
 
Note- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docxNote- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docx
VictorzH8Bondx
 
So I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfSo I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdf
aksahnan
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
arrowmobile
 
Note- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdfNote- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdf
Stewart29UReesa
 
Use the singly linked list class introduced in the lab to implement .pdf
Use the singly linked list class introduced in the lab to implement .pdfUse the singly linked list class introduced in the lab to implement .pdf
Use the singly linked list class introduced in the lab to implement .pdf
sales87
 
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdfLab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
QalandarBux2
 
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdf
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdfCopy your completed LinkedList class from Lab 3 into the LinkedList..pdf
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdf
facevenky
 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdf
contact41
 
Create a new java class called ListNode. Implement ListNode as a gen.pdf
Create a new java class called ListNode. Implement ListNode as a gen.pdfCreate a new java class called ListNode. Implement ListNode as a gen.pdf
Create a new java class called ListNode. Implement ListNode as a gen.pdf
mohamednihalshahru
 
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdfClass DiagramIn the Assignment #10, you are given three files Ass.pdf
Class DiagramIn the Assignment #10, you are given three files Ass.pdf
xlynettalampleyxc
 
Note             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfNote             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdf
Ankitchhabra28
 
hi i have to write a java program involving link lists. i have a pro.pdf
hi i have to write a java program involving link lists. i have a pro.pdfhi i have to write a java program involving link lists. i have a pro.pdf
hi i have to write a java program involving link lists. i have a pro.pdf
archgeetsenterprises
 

More from sales88 (20)

Caso de empresa Hamburguesa In-N-Out el valor del cliente a la an.pdf
Caso de empresa Hamburguesa In-N-Out el valor del cliente a la an.pdfCaso de empresa Hamburguesa In-N-Out el valor del cliente a la an.pdf
Caso de empresa Hamburguesa In-N-Out el valor del cliente a la an.pdf
sales88
 
CASO 6.2 Algunos ciudadanos preocupados hicieron una cita para reu.pdf
CASO 6.2 Algunos ciudadanos preocupados hicieron una cita para reu.pdfCASO 6.2 Algunos ciudadanos preocupados hicieron una cita para reu.pdf
CASO 6.2 Algunos ciudadanos preocupados hicieron una cita para reu.pdf
sales88
 
Caso de EstudioLiderazgo y Gesti�nLaura es directora asocia.pdf
Caso de EstudioLiderazgo y Gesti�nLaura es directora asocia.pdfCaso de EstudioLiderazgo y Gesti�nLaura es directora asocia.pdf
Caso de EstudioLiderazgo y Gesti�nLaura es directora asocia.pdf
sales88
 
Caso de estudio Hacer que las alianzas estrat�gicas y las redes f.pdf
Caso de estudio Hacer que las alianzas estrat�gicas y las redes f.pdfCaso de estudio Hacer que las alianzas estrat�gicas y las redes f.pdf
Caso de estudio Hacer que las alianzas estrat�gicas y las redes f.pdf
sales88
 
CASO DE ESTUDIO La cl�nica Mayo es uno de los nombres m�s respetad.pdf
CASO DE ESTUDIO La cl�nica Mayo es uno de los nombres m�s respetad.pdfCASO DE ESTUDIO La cl�nica Mayo es uno de los nombres m�s respetad.pdf
CASO DE ESTUDIO La cl�nica Mayo es uno de los nombres m�s respetad.pdf
sales88
 
CASO DE ESTUDIO La �pera de Sydney es uno de los edificios ic�nico.pdf
CASO DE ESTUDIO La �pera de Sydney es uno de los edificios ic�nico.pdfCASO DE ESTUDIO La �pera de Sydney es uno de los edificios ic�nico.pdf
CASO DE ESTUDIO La �pera de Sydney es uno de los edificios ic�nico.pdf
sales88
 
Caso de estudio Despu�s de luchar con la deuda y la fuerte compete.pdf
Caso de estudio Despu�s de luchar con la deuda y la fuerte compete.pdfCaso de estudio Despu�s de luchar con la deuda y la fuerte compete.pdf
Caso de estudio Despu�s de luchar con la deuda y la fuerte compete.pdf
sales88
 
Caso cl�nicoSDRAPregunta 1.Dados sus s�ntomas de fatiga, disne.pdf
Caso cl�nicoSDRAPregunta 1.Dados sus s�ntomas de fatiga, disne.pdfCaso cl�nicoSDRAPregunta 1.Dados sus s�ntomas de fatiga, disne.pdf
Caso cl�nicoSDRAPregunta 1.Dados sus s�ntomas de fatiga, disne.pdf
sales88
 
Caso 21-3 Orden de prueba de deterioro Five Star Hotel Corporati.pdf
Caso 21-3 Orden de prueba de deterioro Five Star Hotel Corporati.pdfCaso 21-3 Orden de prueba de deterioro Five Star Hotel Corporati.pdf
Caso 21-3 Orden de prueba de deterioro Five Star Hotel Corporati.pdf
sales88
 
Caso 6.2 Seguro Mar�timo Cl�usula Inchmaree Un barco pesquero c.pdf
Caso 6.2 Seguro Mar�timo Cl�usula Inchmaree Un barco pesquero c.pdfCaso 6.2 Seguro Mar�timo Cl�usula Inchmaree Un barco pesquero c.pdf
Caso 6.2 Seguro Mar�timo Cl�usula Inchmaree Un barco pesquero c.pdf
sales88
 
Caso 3.1 Firma de contadores Moss y McAdams Bruce Palmer hab�a t.pdf
Caso 3.1 Firma de contadores Moss y McAdams Bruce Palmer hab�a t.pdfCaso 3.1 Firma de contadores Moss y McAdams Bruce Palmer hab�a t.pdf
Caso 3.1 Firma de contadores Moss y McAdams Bruce Palmer hab�a t.pdf
sales88
 
Caso 2 (TV de Alta Definici�n La Gran Alianza) (1) Seg�n el caso .pdf
Caso 2 (TV de Alta Definici�n La Gran Alianza) (1) Seg�n el caso .pdfCaso 2 (TV de Alta Definici�n La Gran Alianza) (1) Seg�n el caso .pdf
Caso 2 (TV de Alta Definici�n La Gran Alianza) (1) Seg�n el caso .pdf
sales88
 
Caso 1 (8 puntos) Miguel y Cinthia Leatch viven en Covington, Ten.pdf
Caso 1 (8 puntos) Miguel y Cinthia Leatch viven en Covington, Ten.pdfCaso 1 (8 puntos) Miguel y Cinthia Leatch viven en Covington, Ten.pdf
Caso 1 (8 puntos) Miguel y Cinthia Leatch viven en Covington, Ten.pdf
sales88
 
Caso 1 Agmmaglobulinemia ligada al X 1. Bill fue testamento duran.pdf
Caso 1 Agmmaglobulinemia ligada al X 1. Bill fue testamento duran.pdfCaso 1 Agmmaglobulinemia ligada al X 1. Bill fue testamento duran.pdf
Caso 1 Agmmaglobulinemia ligada al X 1. Bill fue testamento duran.pdf
sales88
 
Caso 1 Felipe R�os y Tiffany De Los Rios married filling jointl.pdf
Caso 1 Felipe R�os  y Tiffany De Los Rios married filling jointl.pdfCaso 1 Felipe R�os  y Tiffany De Los Rios married filling jointl.pdf
Caso 1 Felipe R�os y Tiffany De Los Rios married filling jointl.pdf
sales88
 
Case studyData Protect and PrivacyHuman beings value their priva.pdf
Case studyData Protect and PrivacyHuman beings value their priva.pdfCase studyData Protect and PrivacyHuman beings value their priva.pdf
Case studyData Protect and PrivacyHuman beings value their priva.pdf
sales88
 
CASE STUDY [30 Marks] Former Tongaat Hulett bosses in court for frau.pdf
CASE STUDY [30 Marks] Former Tongaat Hulett bosses in court for frau.pdfCASE STUDY [30 Marks] Former Tongaat Hulett bosses in court for frau.pdf
CASE STUDY [30 Marks] Former Tongaat Hulett bosses in court for frau.pdf
sales88
 
case study Private Practice Implements Safeguards for Waiting .pdf
case study Private Practice Implements Safeguards for Waiting .pdfcase study Private Practice Implements Safeguards for Waiting .pdf
case study Private Practice Implements Safeguards for Waiting .pdf
sales88
 
Case Study Liberty and the Elderly Patient Ronald is 71 years old..pdf
Case Study Liberty and the Elderly Patient Ronald is 71 years old..pdfCase Study Liberty and the Elderly Patient Ronald is 71 years old..pdf
Case Study Liberty and the Elderly Patient Ronald is 71 years old..pdf
sales88
 
Case Study AMr. P tripped and broke her left hip while attempting.pdf
Case Study AMr. P tripped and broke her left hip while attempting.pdfCase Study AMr. P tripped and broke her left hip while attempting.pdf
Case Study AMr. P tripped and broke her left hip while attempting.pdf
sales88
 
Caso de empresa Hamburguesa In-N-Out el valor del cliente a la an.pdf
Caso de empresa Hamburguesa In-N-Out el valor del cliente a la an.pdfCaso de empresa Hamburguesa In-N-Out el valor del cliente a la an.pdf
Caso de empresa Hamburguesa In-N-Out el valor del cliente a la an.pdf
sales88
 
CASO 6.2 Algunos ciudadanos preocupados hicieron una cita para reu.pdf
CASO 6.2 Algunos ciudadanos preocupados hicieron una cita para reu.pdfCASO 6.2 Algunos ciudadanos preocupados hicieron una cita para reu.pdf
CASO 6.2 Algunos ciudadanos preocupados hicieron una cita para reu.pdf
sales88
 
Caso de EstudioLiderazgo y Gesti�nLaura es directora asocia.pdf
Caso de EstudioLiderazgo y Gesti�nLaura es directora asocia.pdfCaso de EstudioLiderazgo y Gesti�nLaura es directora asocia.pdf
Caso de EstudioLiderazgo y Gesti�nLaura es directora asocia.pdf
sales88
 
Caso de estudio Hacer que las alianzas estrat�gicas y las redes f.pdf
Caso de estudio Hacer que las alianzas estrat�gicas y las redes f.pdfCaso de estudio Hacer que las alianzas estrat�gicas y las redes f.pdf
Caso de estudio Hacer que las alianzas estrat�gicas y las redes f.pdf
sales88
 
CASO DE ESTUDIO La cl�nica Mayo es uno de los nombres m�s respetad.pdf
CASO DE ESTUDIO La cl�nica Mayo es uno de los nombres m�s respetad.pdfCASO DE ESTUDIO La cl�nica Mayo es uno de los nombres m�s respetad.pdf
CASO DE ESTUDIO La cl�nica Mayo es uno de los nombres m�s respetad.pdf
sales88
 
CASO DE ESTUDIO La �pera de Sydney es uno de los edificios ic�nico.pdf
CASO DE ESTUDIO La �pera de Sydney es uno de los edificios ic�nico.pdfCASO DE ESTUDIO La �pera de Sydney es uno de los edificios ic�nico.pdf
CASO DE ESTUDIO La �pera de Sydney es uno de los edificios ic�nico.pdf
sales88
 
Caso de estudio Despu�s de luchar con la deuda y la fuerte compete.pdf
Caso de estudio Despu�s de luchar con la deuda y la fuerte compete.pdfCaso de estudio Despu�s de luchar con la deuda y la fuerte compete.pdf
Caso de estudio Despu�s de luchar con la deuda y la fuerte compete.pdf
sales88
 
Caso cl�nicoSDRAPregunta 1.Dados sus s�ntomas de fatiga, disne.pdf
Caso cl�nicoSDRAPregunta 1.Dados sus s�ntomas de fatiga, disne.pdfCaso cl�nicoSDRAPregunta 1.Dados sus s�ntomas de fatiga, disne.pdf
Caso cl�nicoSDRAPregunta 1.Dados sus s�ntomas de fatiga, disne.pdf
sales88
 
Caso 21-3 Orden de prueba de deterioro Five Star Hotel Corporati.pdf
Caso 21-3 Orden de prueba de deterioro Five Star Hotel Corporati.pdfCaso 21-3 Orden de prueba de deterioro Five Star Hotel Corporati.pdf
Caso 21-3 Orden de prueba de deterioro Five Star Hotel Corporati.pdf
sales88
 
Caso 6.2 Seguro Mar�timo Cl�usula Inchmaree Un barco pesquero c.pdf
Caso 6.2 Seguro Mar�timo Cl�usula Inchmaree Un barco pesquero c.pdfCaso 6.2 Seguro Mar�timo Cl�usula Inchmaree Un barco pesquero c.pdf
Caso 6.2 Seguro Mar�timo Cl�usula Inchmaree Un barco pesquero c.pdf
sales88
 
Caso 3.1 Firma de contadores Moss y McAdams Bruce Palmer hab�a t.pdf
Caso 3.1 Firma de contadores Moss y McAdams Bruce Palmer hab�a t.pdfCaso 3.1 Firma de contadores Moss y McAdams Bruce Palmer hab�a t.pdf
Caso 3.1 Firma de contadores Moss y McAdams Bruce Palmer hab�a t.pdf
sales88
 
Caso 2 (TV de Alta Definici�n La Gran Alianza) (1) Seg�n el caso .pdf
Caso 2 (TV de Alta Definici�n La Gran Alianza) (1) Seg�n el caso .pdfCaso 2 (TV de Alta Definici�n La Gran Alianza) (1) Seg�n el caso .pdf
Caso 2 (TV de Alta Definici�n La Gran Alianza) (1) Seg�n el caso .pdf
sales88
 
Caso 1 (8 puntos) Miguel y Cinthia Leatch viven en Covington, Ten.pdf
Caso 1 (8 puntos) Miguel y Cinthia Leatch viven en Covington, Ten.pdfCaso 1 (8 puntos) Miguel y Cinthia Leatch viven en Covington, Ten.pdf
Caso 1 (8 puntos) Miguel y Cinthia Leatch viven en Covington, Ten.pdf
sales88
 
Caso 1 Agmmaglobulinemia ligada al X 1. Bill fue testamento duran.pdf
Caso 1 Agmmaglobulinemia ligada al X 1. Bill fue testamento duran.pdfCaso 1 Agmmaglobulinemia ligada al X 1. Bill fue testamento duran.pdf
Caso 1 Agmmaglobulinemia ligada al X 1. Bill fue testamento duran.pdf
sales88
 
Caso 1 Felipe R�os y Tiffany De Los Rios married filling jointl.pdf
Caso 1 Felipe R�os  y Tiffany De Los Rios married filling jointl.pdfCaso 1 Felipe R�os  y Tiffany De Los Rios married filling jointl.pdf
Caso 1 Felipe R�os y Tiffany De Los Rios married filling jointl.pdf
sales88
 
Case studyData Protect and PrivacyHuman beings value their priva.pdf
Case studyData Protect and PrivacyHuman beings value their priva.pdfCase studyData Protect and PrivacyHuman beings value their priva.pdf
Case studyData Protect and PrivacyHuman beings value their priva.pdf
sales88
 
CASE STUDY [30 Marks] Former Tongaat Hulett bosses in court for frau.pdf
CASE STUDY [30 Marks] Former Tongaat Hulett bosses in court for frau.pdfCASE STUDY [30 Marks] Former Tongaat Hulett bosses in court for frau.pdf
CASE STUDY [30 Marks] Former Tongaat Hulett bosses in court for frau.pdf
sales88
 
case study Private Practice Implements Safeguards for Waiting .pdf
case study Private Practice Implements Safeguards for Waiting .pdfcase study Private Practice Implements Safeguards for Waiting .pdf
case study Private Practice Implements Safeguards for Waiting .pdf
sales88
 
Case Study Liberty and the Elderly Patient Ronald is 71 years old..pdf
Case Study Liberty and the Elderly Patient Ronald is 71 years old..pdfCase Study Liberty and the Elderly Patient Ronald is 71 years old..pdf
Case Study Liberty and the Elderly Patient Ronald is 71 years old..pdf
sales88
 
Case Study AMr. P tripped and broke her left hip while attempting.pdf
Case Study AMr. P tripped and broke her left hip while attempting.pdfCase Study AMr. P tripped and broke her left hip while attempting.pdf
Case Study AMr. P tripped and broke her left hip while attempting.pdf
sales88
 

Recently uploaded (20)

What are the Features & Functions of Odoo 18 SMS Marketing
What are the Features & Functions of Odoo 18 SMS MarketingWhat are the Features & Functions of Odoo 18 SMS Marketing
What are the Features & Functions of Odoo 18 SMS Marketing
Celine George
 
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
Arshad Shaikh
 
Oedipus The King Student Revision Booklet
Oedipus The King Student Revision BookletOedipus The King Student Revision Booklet
Oedipus The King Student Revision Booklet
jpinnuck
 
Exploring Identity Through Colombian Companies
Exploring Identity Through Colombian CompaniesExploring Identity Through Colombian Companies
Exploring Identity Through Colombian Companies
OlgaLeonorTorresSnch
 
How to Configure Subcontracting in Odoo 18 Manufacturing
How to Configure Subcontracting in Odoo 18 ManufacturingHow to Configure Subcontracting in Odoo 18 Manufacturing
How to Configure Subcontracting in Odoo 18 Manufacturing
Celine George
 
How to Setup Renewal of Subscription in Odoo 18
How to Setup Renewal of Subscription in Odoo 18How to Setup Renewal of Subscription in Odoo 18
How to Setup Renewal of Subscription in Odoo 18
Celine George
 
QUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptx
QUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptxQUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptx
QUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptx
Sourav Kr Podder
 
Uterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managmentUterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managment
Ritu480198
 
THE CHURCH AND ITS IMPACT: FOSTERING CHRISTIAN EDUCATION
THE CHURCH AND ITS IMPACT: FOSTERING CHRISTIAN EDUCATIONTHE CHURCH AND ITS IMPACT: FOSTERING CHRISTIAN EDUCATION
THE CHURCH AND ITS IMPACT: FOSTERING CHRISTIAN EDUCATION
PROF. PAUL ALLIEU KAMARA
 
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
Jenny408767
 
"Dictyoptera: The Order of Cockroaches and Mantises" Or, more specifically: ...
"Dictyoptera: The Order of Cockroaches and Mantises"  Or, more specifically: ..."Dictyoptera: The Order of Cockroaches and Mantises"  Or, more specifically: ...
"Dictyoptera: The Order of Cockroaches and Mantises" Or, more specifically: ...
Arshad Shaikh
 
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
wygalkelceqg
 
Network Security Essentials 6th Edition.pdf
Network Security Essentials 6th Edition.pdfNetwork Security Essentials 6th Edition.pdf
Network Security Essentials 6th Edition.pdf
datmieu2004
 
Types of Actions in Odoo 18 - Odoo Slides
Types of Actions in Odoo 18 - Odoo SlidesTypes of Actions in Odoo 18 - Odoo Slides
Types of Actions in Odoo 18 - Odoo Slides
Celine George
 
Education Funding Equity in North Carolina: Looking Beyond Income
Education Funding Equity in North Carolina: Looking Beyond IncomeEducation Funding Equity in North Carolina: Looking Beyond Income
Education Funding Equity in North Carolina: Looking Beyond Income
EducationNC
 
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptxQUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
Sourav Kr Podder
 
How to Setup Lunch in Odoo 18 - Odoo guides
How to Setup Lunch in Odoo 18 - Odoo guidesHow to Setup Lunch in Odoo 18 - Odoo guides
How to Setup Lunch in Odoo 18 - Odoo guides
Celine George
 
How to Manage Orders in Odoo 18 Lunch - Odoo Slides
How to Manage Orders in Odoo 18 Lunch - Odoo SlidesHow to Manage Orders in Odoo 18 Lunch - Odoo Slides
How to Manage Orders in Odoo 18 Lunch - Odoo Slides
Celine George
 
0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx
0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx
0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx
Julián Jesús Pérez Fernández
 
Multicultural approach in education - B.Ed
Multicultural approach in education - B.EdMulticultural approach in education - B.Ed
Multicultural approach in education - B.Ed
prathimagowda443
 
What are the Features & Functions of Odoo 18 SMS Marketing
What are the Features & Functions of Odoo 18 SMS MarketingWhat are the Features & Functions of Odoo 18 SMS Marketing
What are the Features & Functions of Odoo 18 SMS Marketing
Celine George
 
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
Arshad Shaikh
 
Oedipus The King Student Revision Booklet
Oedipus The King Student Revision BookletOedipus The King Student Revision Booklet
Oedipus The King Student Revision Booklet
jpinnuck
 
Exploring Identity Through Colombian Companies
Exploring Identity Through Colombian CompaniesExploring Identity Through Colombian Companies
Exploring Identity Through Colombian Companies
OlgaLeonorTorresSnch
 
How to Configure Subcontracting in Odoo 18 Manufacturing
How to Configure Subcontracting in Odoo 18 ManufacturingHow to Configure Subcontracting in Odoo 18 Manufacturing
How to Configure Subcontracting in Odoo 18 Manufacturing
Celine George
 
How to Setup Renewal of Subscription in Odoo 18
How to Setup Renewal of Subscription in Odoo 18How to Setup Renewal of Subscription in Odoo 18
How to Setup Renewal of Subscription in Odoo 18
Celine George
 
QUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptx
QUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptxQUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptx
QUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptx
Sourav Kr Podder
 
Uterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managmentUterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managment
Ritu480198
 
THE CHURCH AND ITS IMPACT: FOSTERING CHRISTIAN EDUCATION
THE CHURCH AND ITS IMPACT: FOSTERING CHRISTIAN EDUCATIONTHE CHURCH AND ITS IMPACT: FOSTERING CHRISTIAN EDUCATION
THE CHURCH AND ITS IMPACT: FOSTERING CHRISTIAN EDUCATION
PROF. PAUL ALLIEU KAMARA
 
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
[2025] Qualtric XM-EX-EXPERT Study Plan | Practice Questions + Exam Details
Jenny408767
 
"Dictyoptera: The Order of Cockroaches and Mantises" Or, more specifically: ...
"Dictyoptera: The Order of Cockroaches and Mantises"  Or, more specifically: ..."Dictyoptera: The Order of Cockroaches and Mantises"  Or, more specifically: ...
"Dictyoptera: The Order of Cockroaches and Mantises" Or, more specifically: ...
Arshad Shaikh
 
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
Active Surveillance For Localized Prostate Cancer A New Paradigm For Clinical...
wygalkelceqg
 
Network Security Essentials 6th Edition.pdf
Network Security Essentials 6th Edition.pdfNetwork Security Essentials 6th Edition.pdf
Network Security Essentials 6th Edition.pdf
datmieu2004
 
Types of Actions in Odoo 18 - Odoo Slides
Types of Actions in Odoo 18 - Odoo SlidesTypes of Actions in Odoo 18 - Odoo Slides
Types of Actions in Odoo 18 - Odoo Slides
Celine George
 
Education Funding Equity in North Carolina: Looking Beyond Income
Education Funding Equity in North Carolina: Looking Beyond IncomeEducation Funding Equity in North Carolina: Looking Beyond Income
Education Funding Equity in North Carolina: Looking Beyond Income
EducationNC
 
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptxQUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
QUIZ-O-FORCE PRELIMINARY ANSWER SLIDE.pptx
Sourav Kr Podder
 
How to Setup Lunch in Odoo 18 - Odoo guides
How to Setup Lunch in Odoo 18 - Odoo guidesHow to Setup Lunch in Odoo 18 - Odoo guides
How to Setup Lunch in Odoo 18 - Odoo guides
Celine George
 
How to Manage Orders in Odoo 18 Lunch - Odoo Slides
How to Manage Orders in Odoo 18 Lunch - Odoo SlidesHow to Manage Orders in Odoo 18 Lunch - Odoo Slides
How to Manage Orders in Odoo 18 Lunch - Odoo Slides
Celine George
 
Multicultural approach in education - B.Ed
Multicultural approach in education - B.EdMulticultural approach in education - B.Ed
Multicultural approach in education - B.Ed
prathimagowda443
 

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 {
  • 4. BufferedReader reader = new BufferedReader(new FileReader("cars.txt")); String line; while ((line = reader.readLine()) != null) { cars.add(line); } reader.close(); } private void updateCarLabel(Label label) { label.setText(cars.get(currentIndex)); } public static void main(String[] args) { launch(args); } } package nusoft.utils; import java.util.NoSuchElementException; import nusoft.Car; public class NuLinkedList { private Node head; private Node tail; private int size; private static class Node { E element; Node prev; Node next; Node(E element, Node prev, Node next) { this.element = element; this.prev = prev; this.next = next; } } public boolean contains(E e) { return indexOf(e) != -1; }
  • 5. public E get(int index) { if (index < 0 || index >= size) { throw new IndexOutOfBoundsException(); } return getNode(index).element; } public int indexOf(E e) { int index = 0; for (Node node = head; node != null; node = node.next) { if (e == null ? node.element == null : e.equals(node.element)) { return index; } index++; } return -1; } public int lastIndexOf(E e) { int index = size - 1; for (Node node = tail; node != null; node = node.prev) { if (e == null ? node.element == null : e.equals(node.element)) { return index; } index--; } return -1; } public E set(int index, E e) { if (index < 0 || index >= size) { throw new IndexOutOfBoundsException(); } Node node = getNode(index); E oldElement = node.element; node.element = e; return oldElement; } public void add(E e) {
  • 6. addLast(e); } public void add(int index, E e) { if (index < 0 || index > size) { throw new IndexOutOfBoundsException(); } if (index == size) { addLast(e); } else { addBefore(getNode(index), e); } } public void addFirst(E e) { if (size == 0) { head = tail = new Node<>(e, null, null); } else { head.prev = new Node<>(e, null, head); head = head.prev; } size++; } public void addLast(E e) { if (size == 0) { head = tail = new Node<>(e, null, null); } else { tail.next = new Node<>(e, tail, null); tail = tail.next; } size++; } public E remove(int index) { if (index < 0 || index >= size) { throw new IndexOutOfBoundsException(); } return remove(getNode(index)); }
  • 7. public E removeFirst() { if (size == 0) { throw new NoSuchElementException(); } return remove(head); } public E removeLast() { if (size == 0) { throw new NoSuchElementException(); } return remove(tail); } public int size() { return size; } private Node getNode(int index) { if (index < size / 2) { Node node = head; for (int i = 0;i < index; i++) { node = node.next; } return node; } else { Node node = tail; for (int i = size - 1; i > index; i--) { node = node.prev; } return node; } } private void addBefore(Node node, E e) { Node newNode = new Node<>(e, node.prev, node); node.prev.next = newNode; node.prev = newNode; size++; }
  • 8. private E remove(Node node) { if (node == head) { head = node.next; } else { node.prev.next = node.next; } if (node == tail) { tail = node.prev; } else { node.next.prev = node.prev; } size--; return node.element; } @Override public String toString() { StringBuilder sb = new StringBuilder("["); for (Node node = head; node != null; node = node.next) { if (node != head) { sb.append(", "); } sb.append(node.element); } sb.append("]"); return sb.toString(); } public void remove(Car lastCar) { // TODO Auto-generated method stub } } ( import java. io. BufferedReader;