В методе move() Мы значит меняем дистанцию через setDistance A в методе print() выводим почему то через приватный dinstance Не нарушаем ли мы инкапсуляцию package com.javarush.task.task21.task2113; import java.util.ArrayList; import java.util.List; /////////////////////////////////////////////////////// public class Hippodrome { public static Hippodrome game; private static List<Horse> horses; public Hippodrome(List<Horse> horses) { this.horses = horses; } public List<Horse> getHorses() { return horses; } public void run () { int count = 0; while (count < 100) { count++; move(); print(); try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } } } public void move () { for (int i = 0; i < horses.size(); i++) { horses.get(i).move(); } } public void print () { for (int i = 0; i < horses.size(); i++) { horses.get(i).print(); // вызывает print() из класса Horse } for (int y = 0; y < 10; y++) { System.out.println(); } } public static void main(String[] args) { game = new Hippodrome(new ArrayList<>()); Horse horse1 = new Horse("First", 3, 0); Horse horse2 = new Horse("Second", 3, 0); Horse horse3 = new Horse("Three", 3, 0); horses = new ArrayList<>(); horses.add(horse1); horses.add(horse2); horses.add(horse3); game.run(); } } //////////////////////////////////////////// package com.javarush.task.task21.task2113; public class Horse { private String name; private double speed; private double distance; public Horse (String name, double speed, double distance) { this.name = name; this.speed = speed; this.distance = distance; } public String getName() { return name; } public void setName(String name) { this.name = name; } public double getSpeed() { return speed; } public void setSpeed(double speed) { this.speed = speed; } public double getDistance() { distance = distance; return distance; } public void setDistance(double distance) { this.distance = distance; } public void move () { setDistance(speed*Math.random()); } public void print () { int t = (int)Math.floor(distance); // почему здесь distance, а не getDistance() String poin = ""; String name = getName(); for (int y = 0; y < t; y++) { poin += "."; } System.out.println(poin + name); } }