title: Simple Object class and records
body: <p>I am currently learning Java and I have done several tutorials. However, each exercise was focused on one part (example learning IO, learning Strings, graphics, etc) but only a few had multiple chapters all mixed in between. This means I have difficulties in making a more complete yet still simple program. </p>
  
  <p>Please see underneath my issue. I am making a "Car class" where I created 4 variables. I am giving the user the option to insert the type of car, the year and other two options. 
  After all values were set, we get to display them. So far so (almost) good. </p>
  
  <pre><code>import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.util.Scanner;
  
  public class Car {
      String make;
      String model;
      int year;
      String plateNumber; 
  
      public  Car() {
      }
  
      // SETS and GETS the type of the Car
      public void setMake (Scanner in) {
          make = in.nextLine();   
      }
  
      public String getMake () {
          System.out.print("Make: " + make);
          return make;
      }
  
      // SETS and GETS the model of the Car
      public void setModel (Scanner in) {
          model = in.nextLine();
      }
      public String getModel () {
          System.out.print("Model: " + model);
          return model;
      }
  
      // SETS and GETS the year of fabrication
      public void setYear(Scanner in) {
          year = in.nextInt();
      }
      public int getYear () {
          System.out.print("Year: " + year);
          return year;
      }
  
      // SETS and GETS the plateNumber;
      public void setPlate (Scanner in) {
          plateNumber = in.nextLine();
      }
      public String getPlate ()
      {
          System.out.print("License: " + plateNumber);
          return plateNumber;
      }   
  
      public static void main(String[] args) throws IOException {
  
          File file = new File("");
          Scanner in = new Scanner(System.in);
  
          if (!file.exists()) {
              FileWriter writeFile = new FileWriter("cars.txt");
          }
  
          // CAR 1 ====================
          Car car1 = new Car();
          System.out.println("Car1: ");
          car1.setMake(in);
          car1.getMake();
          car1.setModel(in);
          car1.getModel();        
          car1.setYear(in);
          car1.getYear(); 
  
          Car [] cars = new Car [5];  // Creates a 5 car array / parking lot
  
      }
  
  }
  </code></pre>
  
  <p>After this it should store the data in a [5] Car Array and then save them to an external txt file. The save to file I will add after I solve the underneath two points.</p>
  
  <p>Now the problems:</p>
  
  <ol>
  <li>How do I make the Scanner and display more elegant. As you can see in the underneath printscreen the data is doubled (print to screen and Scanner shows the type of car twice)</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/A5URv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A5URv.jpg" alt="enter image description here"></a></p>
  
  <ol start="2">
  <li>How do I store the Car variables in one Array then print only the model or only the year of fabrication, or for Car one, all the values of this car.
  I know how to make an Array of String, int or double. I just don't know how to store the above variables inside a Car array and get the car1 array values one by one. It puzzles me.
  Thanks in advance and best regards,</li>
  </ol>