Загрузка данных


class Animal {
    private String name;

    public Animal(String name) {
        this.name = name;
    }

    public void makeSound() {
        System.out.println("Животное издает звук");
    }

    public String getName() {
        return name;
    }
}


class Dog extends Animal {

    public Dog(String name) {
        super(name);
    }

    @Override
    public void makeSound() {
        System.out.println("Собака: Гав!");
    }
}


class Cat extends Animal {

    public Cat(String name) {
        super(name);
    }

    @Override
    public void makeSound() {
        System.out.println("Кошка: Мяу!");
    }
}


public class Main {
    public static void main(String[] args) {

        Dog dog = new Dog("Бобик");
        Cat cat = new Cat("Мурка");

        System.out.println("Имя собаки: " + dog.getName());
        dog.makeSound();

        System.out.println("Имя кошки: " + cat.getName());
        cat.makeSound();
    }
}


class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void introduce() {
        System.out.println("Меня зовут " + name);
    }

    public String getName() {
        return name;
    }
}


class Student extends Person {
    private String group;

    public Student(String name, int age, String group) {
        super(name, age);
        this.group = group;
    }

    @Override
    public void introduce() {
        super.introduce();

        System.out.println(
                "Меня зовут " + getName()
                + ", я учусь в группе " + group
        );
    }
}


public class Main {
    public static void main(String[] args) {

        Student student = new Student(
                "Иван",
                20,
                "ИВТ-101"
        );

        student.introduce();
    }
}


class Device {
    private String brand;
    private String model;

    public Device(String brand, String model) {
        this.brand = brand;
        this.model = model;
    }

    public void showInfo() {
        System.out.println("Бренд: " + brand);
        System.out.println("Модель: " + model);
    }
}


class Computer extends Device {
    private int ram;

    public Computer(String brand, String model, int ram) {
        super(brand, model);
        this.ram = ram;
    }

    public void showRam() {
        System.out.println("Оперативная память: " + ram + " ГБ");
    }

    @Override
    public void showInfo() {
        super.showInfo();
        System.out.println("Оперативная память: " + ram + " ГБ");
    }
}


class Laptop extends Computer {
    private int batteryCapacity;

    public Laptop(
            String brand,
            String model,
            int ram,
            int batteryCapacity
    ) {
        super(brand, model, ram);
        this.batteryCapacity = batteryCapacity;
    }

    public void charge() {
        System.out.println("Ноутбук заряжается");
    }

    @Override
    public void showInfo() {
        super.showInfo();
        System.out.println(
                "Ёмкость батареи: "
                + batteryCapacity
                + " мАч"
        );
    }
}


class DesktopComputer extends Computer {
    private int powerSupply;

    public DesktopComputer(
            String brand,
            String model,
            int ram,
            int powerSupply
    ) {
        super(brand, model, ram);
        this.powerSupply = powerSupply;
    }

    public void turnOn() {
        System.out.println("Компьютер включается");
    }

    @Override
    public void showInfo() {
        super.showInfo();
        System.out.println(
                "Мощность блока питания: "
                + powerSupply
                + " Вт"
        );
    }
}


class Smartphone extends Device {
    private double screenSize;

    public Smartphone(
            String brand,
            String model,
            double screenSize
    ) {
        super(brand, model);
        this.screenSize = screenSize;
    }

    public void call() {
        System.out.println("Смартфон звонит");
    }

    @Override
    public void showInfo() {
        super.showInfo();
        System.out.println(
                "Размер экрана: "
                + screenSize
                + " дюймов"
        );
    }
}


public class Main {
    public static void main(String[] args) {

        Laptop laptop = new Laptop(
                "Lenovo",
                "IdeaPad",
                16,
                5000
        );

        DesktopComputer desktop = new DesktopComputer(
                "HP",
                "ProDesk",
                32,
                650
        );

        Smartphone smartphone = new Smartphone(
                "Samsung",
                "Galaxy S24",
                6.2
        );


        System.out.println("=== Ноутбук ===");
        laptop.showInfo();
        laptop.charge();


        System.out.println();


        System.out.println("=== Настольный компьютер ===");
        desktop.showInfo();
        desktop.turnOn();


        System.out.println();


        System.out.println("=== Смартфон ===");
        smartphone.showInfo();
        smartphone.call();
    }
}