W
W
Wet_Dumplings2018-12-24 12:44:53
Java
Wet_Dumplings, 2018-12-24 12:44:53

What type of variable to choose for car records?

Hey!
It is necessary to make records about the cars: number, make, name of the owner, date of the last repair (dd.mm.yy), day by which the car should be repaired (dd.mm.yy) and subsequently sort them. What type of variables is this (that multiple "records" refer to one)?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Eremin, 2018-12-24
@EreminD

Welcome to OOP

A
alfss, 2018-12-24
@alfss

https://habr.com/post/274811/
https://habr.com/post/274905/
https://o7planning.org/ru/11571/data-types-in-java...

O
Orkhan, 2018-12-24
Hasanly @azerphoenix

Hello!
1) All the data types you have specified, except date, are of type String. Anything related to dates the Date class (as an option)
2) Of course, I don't know what exactly you are trying to implement to offer a good solution, but you can for example create a simple Car class (pojo) with the types of variables you need. For example,

public class Car {
  private String carNumber, carModel, carOwner;
  private Date lastRepairDate, repairedDate;

  // Constructors
  public Car() {}

  public Car(String carNumber, String carModel, String carOwner, Date lastRepairDate, Date repairedDate) {
    this.carNumber = carNumber;
    this.carModel = carModel;
    this.carOwner = carOwner;
    this.lastRepairDate = lastRepairDate;
    this.repairedDate = repairedDate;
  }

  // Getters & Setters 

  // toString()
}

And then create an ArrayList and store them there ... Although, it would be nice to have a database (sqlite is enough) and store the data in the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question