Intern — Senior
Implementation of the computer purchase method
livecode
Task condition
It is necessary to implement the method buyComputers. It takes a list of Computer objects. When adding each computer, its price should increase by 10%, after which all computers are stored in the internal list inventory of the ComputerShop class.
public class Computer {
private double cost;
public Computer(float cost) {
this.cost = cost;
}
public void start() {
System.out.println("Computer is turned on");
}
public void setCost(double cost) {
this.cost = cost;
}
public double getCost() {
return cost;
}
}
public class ComputerShop {
private List<Computer> inventory;
public void buyComputers(List<Computer> incoming) {
// implementation will increase the price of each computer by 10% and add to inventory
}
}