Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Vehicle;
- public class Vehicle {
- private String bodystyle;
- private String carsegment;
- private int size;
- private int fuel;
- private String purpose;
- public Vehicle(String bodystyle, String carsegment, int size, int fuel, String purpose) {
- this.bodystyle = bodystyle;
- this.carsegment = carsegment;
- this.size = size;
- this.fuel = fuel;
- this.purpose = purpose;
- }
- public String getBodystyle() {
- return bodystyle;
- }
- public void setBodystyle(String bodystyle) {
- this.bodystyle = bodystyle;
- }
- public String getCarsegment() {
- return carsegment;
- }
- public void setCarsegment(String carsegment) {
- this.carsegment = carsegment;
- }
- public int getSize() {
- return size;
- }
- public void setSize(int size) {
- this.size = size;
- }
- public int getFuel() {
- return fuel;
- }
- public void setFuel(int fuel) {
- this.fuel = fuel;
- }
- public String getPurpose() {
- return purpose;
- }
- public void setPurpose(String purpose) {
- this.purpose = purpose;
- }
- @Override
- public String toString() {
- return "Vehicle{" +
- "bodystyle='" + bodystyle + '\'' +
- ", carsegment='" + carsegment + '\'' +
- ", size=" + size +
- ", fuel=" + fuel +
- ", purpose='" + purpose + '\'' +
- '}';
- }
- }
- package Vehicle;
- public class WheeledMotor extends Vehicle{
- private String companyname;
- public WheeledMotor(String bodystyle, String carsegment, int size, int fuel, String purpose, String companyname) {
- super(bodystyle, carsegment, size, fuel, purpose);
- this.companyname = companyname;
- }
- public String getCompanyname() {
- return companyname;
- }
- public void setCompanyname(String companyname) {
- this.companyname = companyname;
- }
- @Override
- public String toString() {
- return "WheeledMotor{" +
- "companyname='" + companyname + '\'' +
- '}';
- }
- }
- package Vehicle;
- public class Car extends WheeledMotor{
- private String license;
- private String issue_state;
- private String model;
- private int year;
- private String color;
- private String identification_no;
- private String make;
- private String body_style;
- 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) {
- super(bodystyle, carsegment, size, fuel, purpose, companyname);
- this.license = license;
- this.issue_state = issue_state;
- this.model = model;
- this.year = year;
- this.color = color;
- this.identification_no = identification_no;
- this.make = make;
- this.body_style = body_style;
- }
- public String getLicense() {
- return license;
- }
- public void setLicense(String license) {
- this.license = license;
- }
- public String getIssue_state() {
- return issue_state;
- }
- public void setIssue_state(String issue_state) {
- this.issue_state = issue_state;
- }
- public String getModel() {
- return model;
- }
- public void setModel(String model) {
- this.model = model;
- }
- public int getYear() {
- return year;
- }
- public void setYear(int year) {
- this.year = year;
- }
- public String getColor() {
- return color;
- }
- public void setColor(String color) {
- this.color = color;
- }
- public String getIdentification_no() {
- return identification_no;
- }
- public void setIdentification_no(String identification_no) {
- this.identification_no = identification_no;
- }
- public String getMake() {
- return make;
- }
- public void setMake(String make) {
- this.make = make;
- }
- public String getBody_style() {
- return body_style;
- }
- public void setBody_style(String body_style) {
- this.body_style = body_style;
- }
- public void driving(){
- System.out.println("Drive");
- }
- public void parking(){
- System.out.println("Park");
- }
- public void passenger_comfort(){
- System.out.println("Comfort");
- }
- public void variety_lights(){
- System.out.println("Lights");
- }
- @Override
- public String toString() {
- return "Car{" +
- "license='" + license + '\'' +
- ", issue_state='" + issue_state + '\'' +
- ", model='" + model + '\'' +
- ", year=" + year +
- ", color='" + color + '\'' +
- ", identification_no='" + identification_no + '\'' +
- ", make='" + make + '\'' +
- ", body_style='" + body_style + '\'' +
- '}';
- }
- }
- package Vehicle;
- public class Main {
- public static void main(String[] args){
- Vehicle vehicle = new Vehicle("N/A","N/A",100,500,"Transportation");
- WheeledMotor wheeledMotor = new WheeledMotor("Cool","N/A",100,500,"Tran","Porsche");
- Car car = new Car("Super cool","N/A",100,500,"Showing off","Porsche","15151abs","19/08/21","Porsche 69",2021,"Yellow","lalalal","Loha","Shundor");
- System.out.println(car);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment