inhuman_Arif

car

Aug 19th, 2021
1,519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.56 KB | None | 0 0
  1. package Vehicle;
  2.  
  3. public class Vehicle {
  4.     private String bodystyle;
  5.     private String carsegment;
  6.     private int size;
  7.     private int fuel;
  8.     private String purpose;
  9.  
  10.     public Vehicle(String bodystyle, String carsegment, int size, int fuel, String purpose) {
  11.         this.bodystyle = bodystyle;
  12.         this.carsegment = carsegment;
  13.         this.size = size;
  14.         this.fuel = fuel;
  15.         this.purpose = purpose;
  16.     }
  17.  
  18.     public String getBodystyle() {
  19.         return bodystyle;
  20.     }
  21.  
  22.     public void setBodystyle(String bodystyle) {
  23.         this.bodystyle = bodystyle;
  24.     }
  25.  
  26.     public String getCarsegment() {
  27.         return carsegment;
  28.     }
  29.  
  30.     public void setCarsegment(String carsegment) {
  31.         this.carsegment = carsegment;
  32.     }
  33.  
  34.     public int getSize() {
  35.         return size;
  36.     }
  37.  
  38.     public void setSize(int size) {
  39.         this.size = size;
  40.     }
  41.  
  42.     public int getFuel() {
  43.         return fuel;
  44.     }
  45.  
  46.     public void setFuel(int fuel) {
  47.         this.fuel = fuel;
  48.     }
  49.  
  50.     public String getPurpose() {
  51.         return purpose;
  52.     }
  53.  
  54.     public void setPurpose(String purpose) {
  55.         this.purpose = purpose;
  56.     }
  57.  
  58.     @Override
  59.     public String toString() {
  60.         return "Vehicle{" +
  61.                 "bodystyle='" + bodystyle + '\'' +
  62.                 ", carsegment='" + carsegment + '\'' +
  63.                 ", size=" + size +
  64.                 ", fuel=" + fuel +
  65.                 ", purpose='" + purpose + '\'' +
  66.                 '}';
  67.     }
  68. }
  69. package Vehicle;
  70.  
  71. public class WheeledMotor extends Vehicle{
  72.     private String companyname;
  73.  
  74.     public WheeledMotor(String bodystyle, String carsegment, int size, int fuel, String purpose, String companyname) {
  75.         super(bodystyle, carsegment, size, fuel, purpose);
  76.         this.companyname = companyname;
  77.     }
  78.  
  79.     public String getCompanyname() {
  80.         return companyname;
  81.     }
  82.  
  83.     public void setCompanyname(String companyname) {
  84.         this.companyname = companyname;
  85.     }
  86.  
  87.     @Override
  88.     public String toString() {
  89.         return "WheeledMotor{" +
  90.                 "companyname='" + companyname + '\'' +
  91.                 '}';
  92.     }
  93. }
  94. package Vehicle;
  95.  
  96. public class Car extends WheeledMotor{
  97.     private String license;
  98.     private String issue_state;
  99.     private String model;
  100.     private int year;
  101.     private String color;
  102.     private String identification_no;
  103.     private String make;
  104.     private String body_style;
  105.  
  106.     public Car(String bodystyle, String carsegment, int size, int fuel, String purpose, String companyname, String license, String issue_state, String model, int year, String color, String identification_no, String make, String body_style) {
  107.         super(bodystyle, carsegment, size, fuel, purpose, companyname);
  108.         this.license = license;
  109.         this.issue_state = issue_state;
  110.         this.model = model;
  111.         this.year = year;
  112.         this.color = color;
  113.         this.identification_no = identification_no;
  114.         this.make = make;
  115.         this.body_style = body_style;
  116.     }
  117.  
  118.     public String getLicense() {
  119.         return license;
  120.     }
  121.  
  122.     public void setLicense(String license) {
  123.         this.license = license;
  124.     }
  125.  
  126.     public String getIssue_state() {
  127.         return issue_state;
  128.     }
  129.  
  130.     public void setIssue_state(String issue_state) {
  131.         this.issue_state = issue_state;
  132.     }
  133.  
  134.     public String getModel() {
  135.         return model;
  136.     }
  137.  
  138.     public void setModel(String model) {
  139.         this.model = model;
  140.     }
  141.  
  142.     public int getYear() {
  143.         return year;
  144.     }
  145.  
  146.     public void setYear(int year) {
  147.         this.year = year;
  148.     }
  149.  
  150.     public String getColor() {
  151.         return color;
  152.     }
  153.  
  154.     public void setColor(String color) {
  155.         this.color = color;
  156.     }
  157.  
  158.     public String getIdentification_no() {
  159.         return identification_no;
  160.     }
  161.  
  162.     public void setIdentification_no(String identification_no) {
  163.         this.identification_no = identification_no;
  164.     }
  165.  
  166.     public String getMake() {
  167.         return make;
  168.     }
  169.  
  170.     public void setMake(String make) {
  171.         this.make = make;
  172.     }
  173.  
  174.     public String getBody_style() {
  175.         return body_style;
  176.     }
  177.  
  178.     public void setBody_style(String body_style) {
  179.         this.body_style = body_style;
  180.     }
  181.     public void driving(){
  182.         System.out.println("Drive");
  183.     }
  184.     public void parking(){
  185.         System.out.println("Park");
  186.     }
  187.     public void passenger_comfort(){
  188.         System.out.println("Comfort");
  189.     }
  190.     public void variety_lights(){
  191.         System.out.println("Lights");
  192.     }
  193.  
  194.     @Override
  195.     public String toString() {
  196.         return "Car{" +
  197.                 "license='" + license + '\'' +
  198.                 ", issue_state='" + issue_state + '\'' +
  199.                 ", model='" + model + '\'' +
  200.                 ", year=" + year +
  201.                 ", color='" + color + '\'' +
  202.                 ", identification_no='" + identification_no + '\'' +
  203.                 ", make='" + make + '\'' +
  204.                 ", body_style='" + body_style + '\'' +
  205.                 '}';
  206.     }
  207. }
  208. package Vehicle;
  209.  
  210. public class Main {
  211.     public static void main(String[] args){
  212.         Vehicle vehicle = new Vehicle("N/A","N/A",100,500,"Transportation");
  213.         WheeledMotor wheeledMotor = new WheeledMotor("Cool","N/A",100,500,"Tran","Porsche");
  214.         Car car = new Car("Super cool","N/A",100,500,"Showing off","Porsche","15151abs","19/08/21","Porsche 69",2021,"Yellow","lalalal","Loha","Shundor");
  215.         System.out.println(car);
  216.     }
  217. }
  218.  
Advertisement
Add Comment
Please, Sign In to add comment