Junior — Senior
Detect defects in code without executing the Runner class
livecode
Task condition
In the project, there are two classes — Runner and ComputerShop. It is required to analyze their source codes and identify potential issues without running the main method of the Runner class.
public class Runner {
public static void main(String[] args) {
ComputerShop computerShop = new ComputerShop();
PhoneShop phoneShop = new PhoneShop();
Computer computer = computerShop.sellComputer();
Phone phone = phoneShop.sellPhone();
computer.start();
phone.call();
}
}
public class ComputerShop {
private List<Computer> computers;
public void buyComputers(List<Computer> computers) {
}
public Computer sellComputer() {
if (computers.size() == 0) {
throw new RuntimeException("Computers are sold out!");
}
return computers.remove(0);
}
}