package Kursovaa2; public class Main { public static void main(String[] args) { Battery battery = new Battery("LItieva", 20, 20); Screen screen = new Screen(4.7, 25000); Phone nokiaN95 = new Phone("95", "Nokia", 25.5, battery, screen); System.out.println(nokiaN95.toString()); } } _______________________________________________ package Kursovaa2; public class Battery { private String model; private double idleTime; private double hoursTalk; public Battery(String model, double idleTime, double hoursTalk) { this.model = model; this.idleTime = idleTime; this.hoursTalk = hoursTalk; } @Override public String toString() { return String.format("Model: %s\n" + "Idle time: %.2f\n" + "Hours talk %.2f\n", this.model, this.idleTime, this.hoursTalk); } } ______________________________________________________ package Kursovaa2; public class Phone { private String model; private String brand; private double price; private String owner; private Battery battery; private Screen screen; public Phone(String model, String brand, double price, Battery battery, Screen screen) { this.model = model; this.brand = brand; this.price = price; this.owner = null; this.battery = battery; this.screen = screen; } ____________________________________________________ public Phone(String model, String brand, double price, String owner, Battery battery, Screen screen) { this.model = model; this.brand = brand; this.price = price; this.owner = owner; this.battery = battery; this.screen = screen; } @Override public String toString() { String result = String.format("%s %s\n" + "Price: %.2f\n", this.brand, this.model, this.price); if (this.owner != null) { result += String.format("Owner: %s", this.owner); } result += battery.toString(); result += screen.toString(); return result; } } _______________________________________ package Kursovaa2; public class Screen { private double size; private int colors; public Screen(double size, int colors) { this.size = size; this.colors = colors; } @Override public String toString() { return String.format("Size: %.2f\n" + "Colors: %d", this.size, this.colors); } }