diff --git a/src/main/java/ru/j4j/oop/Car.java b/src/main/java/ru/j4j/oop/Car.java new file mode 100644 index 0000000..a0feab7 --- /dev/null +++ b/src/main/java/ru/j4j/oop/Car.java @@ -0,0 +1,42 @@ +package ru.j4j.oop; + +public class Car { + private String brand; + private String model; + + public Car(String brand, String model) { + this.brand = brand; + this.model = model; + } + + public void startEngine() { + System.out.println("Двигатель запущен"); + } + + public class Transmission { + + public void accelerate() { + System.out.println("Ускорение"); + } + + } + + public class Brakes { + + public void brake() { + System.out.println("Торможение"); + } + + } + + public class TripComputer { + + public String tripData = "Бортовой компьютер"; + private String model = "Модель TripComputer"; + + public void getInfo() { + System.out.println("Модель TripComputer: " + this.model); + System.out.println("Модель Car: " + Car.this.model); + } + } +} \ No newline at end of file diff --git a/src/main/java/ru/j4j/oop/CarMain.java b/src/main/java/ru/j4j/oop/CarMain.java new file mode 100644 index 0000000..0405543 --- /dev/null +++ b/src/main/java/ru/j4j/oop/CarMain.java @@ -0,0 +1,14 @@ +package ru.j4j.oop; + +public class CarMain { + public static void main(String[] args) { + Car car = new Car("Марка", "Модель"); + Car.Transmission transmission = car.new Transmission(); + Car.TripComputer tripComputer = car.new TripComputer(); + Car.Brakes brakes = car.new Brakes(); + car.startEngine(); + transmission.accelerate(); + brakes.brake(); + tripComputer.getInfo(); + } +} diff --git a/src/main/java/ru/j4j/oop/OuterClass.java b/src/main/java/ru/j4j/oop/OuterClass.java new file mode 100644 index 0000000..626b0ae --- /dev/null +++ b/src/main/java/ru/j4j/oop/OuterClass.java @@ -0,0 +1,10 @@ +package ru.j4j.oop; + +public class OuterClass { + class NestedClass { + } + + static class StaticNestedClass { + } + +}