-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevice.java
More file actions
61 lines (44 loc) · 1.82 KB
/
Device.java
File metadata and controls
61 lines (44 loc) · 1.82 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
// Represents a device in the library system. Each device has a SKU, a name, and an availability status.
public class Device {
// Private variables to hold the device's SKU, name, and availability status
private String sku;
private String name;
private boolean isAvailable;
// Constructor to create a new device with specified details.
//sku The stock keeping unit identifier for the device.
//name The name of the device.
//isAvailable The availability status of the device, true if available.
public Device(String sku, String name, boolean isAvailable) {
this.sku = sku; // Assign the SKU
this.name = name; // Assign the name
this.isAvailable = isAvailable; // Set the availability status
}
// Gets the SKU of the device and returns The SKU as a String.
public String getSku() {
return sku;
}
//Sets the SKU of the device.
public void setSku(String sku) {
this.sku = sku; // Update the device's SKU
}
// Gets the name of the device and return The name of the device as a String.
public String getName() {
return name;
}
//Sets the name of the device.
public void setName(String name) {
this.name = name; // Update the device's name
}
// Checks if the device is available for checkout and returns true if the device is available, false otherwise.
public boolean isAvailable() {
return isAvailable;
}
//Sets the availability of the device.
public void setAvailable(boolean available) {
this.isAvailable = available; // Update the device's availability status
}
@Override
public String toString() {
return String.format("SKU: %s - Name: %s - Available: %s", sku, name, isAvailable ? "Yes" : "No");
}
}