Answer to Question #279324 in Java | JSP | JSF for syahidah

Question #279324

Given the definition of Laptop class as follows:

public class Laptop

{

  private String brand;  //HP, Acer, ASUS

  private double price;  //price per unit

  private int RAM;    // memory space in GigaByte(GB),e.g:2,4

  private int USBport;   //number of USB port e.g:2, 3, 4

   

  //normal constructor: public Laptop (String, double, int, int)

  //processor method: upradeRAM(int)

  //accessors: getBrand (), getPrice(), getRAM(), getUSB()

}

1. Write full class definition for the Laptop class.


1
Expert's answer
2021-12-13T16:57:18-0500
public class Laptop {
  private String brand;  //HP, Acer, ASUS
  private double price;  //price per unit
  private int RAM;    // memory space in GigaByte(GB),e.g:2,4
  private int USBport;   //number of USB port e.g:2, 3, 4

  public Laptop (String brand, double price, int RAM, int USDport) {
    this.brand=brand;
    this.price=price;
    this.RAM=RAM;
    this.USDport=USDport;
  }
  
  void upgradeRAM(int n) {
    this.RAM += n;
  }

  public String getBrand() { return brand; }
  public double getPrice() { return price; }
  public int getRAM() { return RAM; }
  public int getUSDport() { return USDport; }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog