0
Hello I am currently trying to create a test program in which the user must inform the data about a car. This car he has his own class with get and set and a builder.
I wanted to take the data of the get and set of the Car class and play in the Main class Arraylist.
public class Main{
Carro car = new Carro();
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
ArrayList<Carro> carros = new ArrayList<>();
System.out.println("Digite o id do carro: ");
}
}
This is the class on car information.
public class Carro {
private int id;
private String placa;
private String modelo;
private String fabricante;
private float preco;
public Carro() {
this.id = id;
this.placa = placa;
this.modelo = modelo;
this.fabricante = fabricante;
this.preco = preco;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPlaca() {
return placa;
}
public void setPlaca(String placa) {
this.placa = placa;
}
public String getModelo() {
return modelo;
}
public void setModelo(String modelo) {
this.modelo = modelo;
}
public String getFabricante() {
return fabricante;
}
public void setFabricante(String fabricante) {
this.fabricante = fabricante;
}
public float getPreco() {
return preco;
}
public void setPreco(float preco) {
this.preco = preco;
}
@Override
public String toString() {
return "Carro{" +
"id=" + id +
", placa='" + placa + '\'' +
", modelo='" + modelo + '\'' +
", fabricante='" + fabricante + '\'' +
", preco=" + preco +
'}';
}
}
Thank you very much helped.
– Carlos Eduardo