Advertisement
SenpaiZero

Car

May 2nd, 2024
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1.  
  2. public class Car {
  3.     private int year;
  4.     private Model model;
  5.     private Color color;
  6.    
  7.     // Constructor for setting the value of data for year, model, and color
  8.     public Car(int year, Model model, Color color) {
  9.         this.year = year;
  10.         this.model = model;
  11.         this.color = color;
  12.     }
  13.    
  14.     // Method for printing the value of variables
  15.     public void print() {
  16.         System.out.println("Model: " + model);
  17.         System.out.println("Color: " + color);
  18.         System.out.println("Year: " + year);
  19.     }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement