-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTesteMemoria.java
More file actions
executable file
·33 lines (24 loc) · 864 Bytes
/
Copy pathTesteMemoria.java
File metadata and controls
executable file
·33 lines (24 loc) · 864 Bytes
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
public class TesteMemoria {
private static void print(String string){
System.out.println(string + "\n");
}
public static void main(String[] args) {
MemoriaS hd = new HD("46327", 10, MemoriaS.MB);
MemoriaS cd = new CD(650, MemoriaS.MB);
// imprimir numero de serie do objeto hd
print("No Serie HD: " + ((HD)hd).getNumeroSerie());
// imprime o percentual de perda do objeto hd
print("Percent de perda HD: " + ((HD)hd).getPerda());
// imprime estado do objeto cd
print("Estado CD: " + ((CD)cd).getEstado());
// os metodos polimorficos
print("Os métodos polimóficos são:\n- getPerda()\n- getEspacoDisponivelRealKB()\n- toString()");
// testa outros métodos
print(hd.toString());
print(cd.toString());
HD hd2 = new HD("125678", 2, HD.GB);
print(hd2.toString());
hd2.GravaKB(1);
print(hd2.toString());
}
}