-
Notifications
You must be signed in to change notification settings - Fork 686
Expand file tree
/
Copy pathCD.java
More file actions
47 lines (38 loc) · 1.36 KB
/
CD.java
File metadata and controls
47 lines (38 loc) · 1.36 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
package org.launchcode;
//This class extends BaseDisc and implements the OpticalDisc interface. It provides the specific implementation for CDs
public class CD extends BaseDisc implements OpticalDisc {
public CD(String name, double storageCapacity) {
super(name, storageCapacity);
}
//Overrides the spinDisc() method to provide CD-specific spinning behavior.
//Implements the methods defined in the OpticalDisc interface for CD-specific behavior
@Override
public void spinDisc() {
// Override spinDisc() method for CD
System.out.println("A CD spins at a rate of " + CD_MIN_SPIN_SPEED + " - " + CD_MAX_SPIN_SPEED + " rpm.");
}
//Stores data on the CD.
@Override
public void storeData(String data) {
// Implementation specific to CD
setContents(data);
}
//Reads data from the CD.
@Override
public String readData() {
// Implementation specific to CD
return getContents();
}
//Writes data to the CD.
@Override
public void writeData(String data) {
// Implementation specific to CD
setContents(data);
}
//Provides CD-specific information about the disc.
@Override
public String discInfo() {
// Implementation specific to CD
return "CD Name: " + getName() + ", Storage Capacity: " + getStorageCapacity() + " MB";
}
}