The main class is the class Computer, where i have all the attributes for the others sub-classes. Some of the attributes are defined randomly and i don't know if I'm setting them in the correct part of the Contructor code or not.
public class Computer {
//Attributes
private int ID;
private int RAM;
private int HDD;
private double CPU;
private String level;
private String architecture;
//Constructors
public Computer() {
String[] possiblesArq = {"x64", "ARM"};
int arqIndex = (int)(Math.random() * possiblesArq.length);
this.architecture = possiblesArq[arqIndex];
}
public Computer(int ID, int RAM, int HDD, float CPU, String level, String architecture) {
//this();
this.ID = ID;
this.RAM = RAM;
this.HDD = HDD;
this.CPU = CPU;
this.level = level;
this.architecture = architecture;
}
class Server extends Computer{
// Constructors
public Server() {
super();
setLevel("Cloud");
Random random = new Random();
setRAM((int)Math.pow(2, (random.nextInt((9 - 7) + 1) + 7)));
setHDD((int)Math.pow(2, (random.nextInt((14 - 10) + 1) + 10)));
setCPU((float)random.nextInt((4 - 3) + 1) + 3);
}
/* public Server(int ID, int RAM, int HDD, double CPU, String level, String architecture) {
this();
this.
}*/```
Should i define in Server() or in Server(attributes) ?
