Skip to content

Commit 279dd71

Browse files
authored
& from seven Spirits which are before his throne
John to the seven churches which are in Asia: Grace [be] unto you, and peace, from him which is, and which was, and which is to come; and from the seven Spirits which are before his throne (Revelation 1:4)
1 parent 5fd66eb commit 279dd71

1 file changed

Lines changed: 124 additions & 0 deletions

File tree

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
2+
//John to the seven churches which are in Asia: Grace [be] unto you, and peace, from him which is, and which was,
3+
//and which is to come; and from the seven Spirits which are before his throne (Revelation 1:4)
4+
5+
package com.javarush.task.task25.task2515;
6+
7+
import java.util.ArrayList;
8+
9+
public class Space {
10+
11+
12+
private int width, height;
13+
14+
private SpaceShip ship;
15+
16+
private ArrayList<Ufo> ufos = new ArrayList<>();
17+
private ArrayList<Rocket> rockets = new ArrayList<>();
18+
private ArrayList<Bomb> bombs = new ArrayList<>();
19+
20+
public Space(int width, int height) {
21+
this.width = width;
22+
this.height = height;
23+
}
24+
25+
public static Space game;
26+
27+
public void run() {}
28+
public void draw() {}
29+
public void sleep(int ms) {}
30+
31+
public static void main(String[] args) {
32+
33+
}
34+
35+
public int getWidth() {
36+
return width;
37+
}
38+
39+
public int getHeight() {
40+
return height;
41+
}
42+
43+
public SpaceShip getShip() {
44+
return ship;
45+
}
46+
47+
public ArrayList<Ufo> getUfos() {
48+
return ufos;
49+
}
50+
51+
public ArrayList<Rocket> getRockets() {
52+
return rockets;
53+
}
54+
55+
public ArrayList<Bomb> getBombs() {
56+
return bombs;
57+
}
58+
59+
public void setShip(SpaceShip ship) {
60+
this.ship = ship;
61+
}
62+
}
63+
64+
/*
65+
Space (10)
66+
67+
Теперь напишем класс Bomb. Тут все просто.
68+
69+
Bomb унаследован от BaseObject.
70+
71+
72+
73+
Надо:
74+
75+
а) изменить конструктор:
76+
77+
Конструктор Bomb должен выглядеть примерно так:
78+
79+
public Bomb(double x, double y)
80+
81+
{
82+
83+
super(x, y, 1);
84+
85+
}
86+
87+
88+
89+
x и y переданные в конструктор Bomb мы передаем дальше в конструктор BaseObject с помощью super, где так же указываем радиус "бомбы" равный 1.
90+
91+
92+
93+
б) написать метод move():
94+
95+
тут все просто - бомба падает вниз - просто увеличиваем y на 1.
96+
97+
98+
99+
в) метод draw(Canvas canvas):
100+
101+
тут тоже не очень сложная логика.
102+
103+
Давай просто ставить точку с координатами (x,y) и "цветом" B:
104+
105+
canvas.setPoint(x,y,'B').
106+
107+
108+
109+
г) Создай в классе Space нашу игру public static Space game.
110+
111+
112+
113+
114+
115+
Требования:
116+
117+
1. В классе Bomb конструктор должен принимать координаты, а радиус выставлять всегда равным 1.
118+
119+
2. В классе Bomb напиши метод move(), который увеличивает координату y на единицу.
120+
121+
3. В классе Bomb напиши метод draw(Canvas canvas), который для canvas будет ставить символ 'B' в координатах x, y.
122+
123+
4. В классе Space создай поле public static Space game.
124+
*/

0 commit comments

Comments
 (0)