-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLaptop.java
More file actions
72 lines (59 loc) · 2.43 KB
/
Laptop.java
File metadata and controls
72 lines (59 loc) · 2.43 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* @author Zachary Devore
* Date: 3/10/26
* Section: CSC 311-002
*/
public class Laptop extends ElectronicItem {
/** Screensize of the laptop */
private double screenSize;
/** Amount of RAM the laptop has in GB */
private int ram;
/**
* Constructor for a Macbook
*/
public Laptop(int itemID, String name, double price, int quantity,
String brand, int warrantyMonths, double powerWatts, boolean isRechargeable,
double screenSize, int ram) {
super(itemID, name, price, quantity, brand, warrantyMonths, powerWatts, isRechargeable); // Calling constructor from ElectronicItem
this.screenSize = screenSize;
this.ram = ram;
}
/**
* Getter for the screen size of the laptop
* @return The screen size of the laptop
*/
public double getScreenSize() {return this.screenSize;}
/**
* Getter for the amount of RAM
* @return The amount of RAM in the laptop
*/
public int getRam() {return this.ram;}
/**
* Sets a new screen size for the laptop
* @param screenSize
*/
public void setScreenSize(double screenSize) {this.screenSize = screenSize;}
/**
* Sets a new RAM amount for the laptop in GB
* @param ram
*/
public void setRAM(int ram) {this.ram = ram;}
/**
* Represents a Laptop with the attributes ItemID, Price, Quantity, Brand, Warrenty Months,
* Power Watts, isRechargable, Screen Size, Ram.
*/
@Override
public String toString() {
return String.format("ItemID: %d| Name: %s| Price: $%.2f| Quantity: %d| Brand: %s| Warrenty Months: %d| Power Consumption in Watts: %.2f| Is Rechargeable? %b| Screen Size: %.2f| RAM: %d",
getItemID(), getName(), getPrice(), getQuantity(), getBrand(), getWarrantyMonths(), getPowerWatts(), getIsRechargable(), getScreenSize(), getRam());
// return "ItemId: " + this.getItemID() +
// "\nPrice: " + this.getPrice() +
// "\nQuantity: " + this.getQuantity() +
// "\nBrand: " + this.getBrand() +
// "\nWarrenty Months: " + this.getWarrentyMonths() +
// "\nPower Watts: " + this.getPowerWatts() +
// "\nisRechargable: " + this.getIsRechargable() +
// "\nScreen Size: " + this.getScreenSize() +
// "\nRam: " + this.getRam();
}
}