-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.java
More file actions
22 lines (18 loc) · 897 Bytes
/
Game.java
File metadata and controls
22 lines (18 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class Game {
public static void main(String[] args) {
// Create individual factories for each type
ObstacleFactory goombaFactory = new GoombaFactory();
ObstacleFactory koopaFactory = new KoopaFactory();
PowerUpFactory mushroomFactory = new MushroomFactory();
PowerUpFactory starFactory = new StarFactory();
// Use factories to create objects
Obstacle goomba = goombaFactory.createObstacle();
goomba.render(); // Output: "Goomba obstacle created!"
Obstacle koopa = koopaFactory.createObstacle();
koopa.render(); // Output: "Koopa obstacle created!"
PowerUp mushroom = mushroomFactory.createPowerUp();
mushroom.activate(); // Output: "Mushroom power-up activated!"
PowerUp star = starFactory.createPowerUp();
star.activate(); // Output: "Star power-up activated!"
}
}