-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVehicle.java
More file actions
45 lines (38 loc) · 968 Bytes
/
Vehicle.java
File metadata and controls
45 lines (38 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
public abstract class Vehicle{
private String brand;
private String model;
private double price;
public Vehicle(String brand,String model,double price){
this.brand=brand;
this.model=model;
this.price=price;
}
//Getters and Setters
public String getBrand(){
return brand;
}
public void setBrand(String brand){
this.brand=brand;
}
public String getModel(){
return model;
}
public void setModel(String model){
this.model=model;
}
public double getPrice(){
return price;
}
public void setPrice(double price){
if(price>0){
this.price=price;
}else{
System.out.println("Invalid Price");
}
}
public abstract void start();
public abstract void stop();
public void displayInfo(){
System.out.println("Brand: "+brand+", Model: "+model+",Price: ₹"+price);
}
}