/
Gnomik61
/
StrangeProject
Обзор
Документация
Войти
/
Gnomik61
/
StrangeProject
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/Person.java
55 строк
976 B
unknown
first_commit
05 ноя 2025, 10:49
05 ноя 2025, 10:49
b316a5e
Код
Авторство
О чём код?
import java.util.Random; public class Person { protected int x, y; private String image = "\uD83C\uDFE9"; private int live = 1; Random r = new Random(); Person(int sizeBoard) { y = sizeBoard; int n = r.nextInt(sizeBoard); x = n == 0 ? 1 : n; } Person(int x, int y){ this.x = x; this.y = y; } Person(){ this(1, 1); } public int getX(){ return x; } public int getY() { return y; } public int getLive() { return live; } public String getImage(){ return image; } public void setImage(String image) { this.image = image; } public boolean moveCorrect(int x, int y){ return this.x == x && Math.abs(this.y - y) == 1 || this.y == y && Math.abs(this.x - x) == 1; } void move(int x, int y){ this.x = x; this.y = y; } public void downLive(){ live--; } }