Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Lol {
  3.     public static Scanner reader = new Scanner(System.in);
  4.     public static void main(String args[]) {
  5.         Car idk = new Car(4,"lambo","white");
  6.         String test = idk.print();
  7.         System.out.println(test);
  8.  
  9.     }
  10. }
  11. =============================================================================
  12. public class Car {
  13.     private int wheels;
  14.     private String model;
  15.     private String color;
  16.     public Car (int wheels , String model , String color)
  17.     {
  18.         this.wheels = wheels;
  19.         this.model = model;
  20.         this.color = color;
  21.     }
  22.  
  23.     public int getWheels() {
  24.         return wheels;
  25.     }
  26.  
  27.     public String getColor() {
  28.         return color;
  29.     }
  30.  
  31.     public String getModel() {
  32.         return model;
  33.     }
  34.  
  35.     public void setColor(String color) {
  36.         this.color = color;
  37.     }
  38.  
  39.     public void setModel(String model) {
  40.         this.model = model;
  41.     }
  42.  
  43.     public void setWheels(int wheels) {
  44.         this.wheels = wheels;
  45.     }
  46.     public String print(){
  47.          String test= " wheels: "+wheels+" model: "+model+" color: "+color;
  48.          return test;
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement