MrThoe

Car.java

Sep 1st, 2022
1,155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. public class Car{
  2.     // Variables
  3.     private int miles;
  4.     private String make;
  5.     private String model;
  6.     private boolean hasBluetooth;
  7.  
  8.     // Constructor Method
  9.     public Car(int m, String mk, String md, boolean hb)
  10.     {
  11.         miles = m;
  12.         make = mk;
  13.         model = md;
  14.         hasBluetooth = hb;
  15.     }
  16.  
  17.     // Methods (functions)
  18.     public void drive(int distance)
  19.     {
  20.         miles += distance;   //miles = miles + distance
  21.     }
  22.  
  23.     public int getMiles()
  24.     {
  25.         return miles;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment