writing constructor methods in java

Solutions on MaxInterview for writing constructor methods in java by the best coders in the world

showing results for - "writing constructor methods in java"
Victoria
26 Jan 2020
1class Vehicle {
2
3              public int mYear;
4              public String mBrand;
5              public String mModel;
6              public int mMiles;
7              public int mPrice;
8
9              public Vehicle(int year, String brand, String model, int miles, int price) {
10                mYear = year;
11                mBrand = brand;
12                mModel = model;
13                mMiles = miles;
14                mPrice = price;
15              }
16
17              public boolean worthBuying(int maxPrice){
18                return (mPrice < maxPrice);
19              }
20
21            }
22
23