In: Computer Science
Create a new project in BlueJ. Create two new classes in the project, with the following specifications:
Class name: Part
Fields:
1 Constructor: takes parameters partId, partDescrip, and partPrice to initialize fields id, description, and price; sets onSale field to false.
Methods: Write get-methods (getters) for all four fields. The getters should be named getId, getDescription, getPrice, and isOnSale.
class Part{
private int id;
private String description;
private double price;
private boolean onScale;
public Part(int aId, String aDescription, double aPrice) {
super();
id = aId;
description = aDescription;
price = aPrice;
onScale=false;
}
public int getId() {
return id;
}
public String getDescription() {
return description;
}
public double getPrice() {
return price;
}
public boolean isOnScale() {
return onScale;
}
}
public class TestPart {
public static void main(String[] args) {
Part p =new Part(1, "Brakes", 100);
System.out.println("Id: "+p.getId());
System.out.println("Description: "+p.getDescription());
System.out.println("Price: "+p.getPrice());
}
}
NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME