@startuml
' --- Pacote Principal ---
package PacManGame {
class Game {
- board: Board
- pacMan: PacMan
- ghosts: List<Ghost>
- score: Score
- inputHandler: InputHandler
- appearanceFactory: AppearanceFactory
+ startGame()
+ update()
+ endGame()
+ changeAppearance(appearanceType: String)
class Board {
- width: int
- height: int
- grid: Cell[][]
+ initialize()
+ getItemAt(x: int, y: int): Item
+ setItemAt(x: int, y: int, item: Item)
class Cell {
- x: int
- y: int
- item: Item
abstract class Item {
+ draw(appearance: Appearance)
class Point extends Item {
class PowerPellet extends Item {
class Wall extends Item {
class Empty extends Item {
class Score {
- points: int
+ addPoints(value: int)
+ getScore(): int
+ reset()
+ draw(appearance: Appearance)
}
class InputHandler {
+ getNextMove(): Direction
enum Direction {
UP
DOWN
LEFT
RIGHT
' --- Pacote PacMan ---
package PacMan {
class PacMan {
- x: int
- y: int
- direction: Direction
+ move(direction: Direction, board: Board)
+ eat(item: Item, score: Score)
+ draw(appearance: Appearance)
' --- Pacote Fantasma ---
package Ghost {
abstract class Ghost {
- x: int
- y: int
- moveStrategy: MoveStrategy
+ setMoveStrategy(strategy: MoveStrategy)
+ move(board: Board, pacMan: PacMan)
+ draw(appearance: Appearance)
interface MoveStrategy {
+ getNextMove(ghost: Ghost, board: Board, pacMan: PacMan): Direction
class RedGhost extends Ghost implements MoveStrategy {
+ getNextMove(ghost: Ghost, board: Board, pacMan: PacMan): Direction
class PinkGhost extends Ghost implements MoveStrategy {
+ getNextMove(ghost: Ghost, board: Board, pacMan: PacMan): Direction
class OrangeGhost extends Ghost implements MoveStrategy {
+ getNextMove(ghost: Ghost, board: Board, pacMan: PacMan): Direction
class WhiteGhost extends Ghost implements MoveStrategy {
+ getNextMove(ghost: Ghost, board: Board, pacMan: PacMan): Direction
' --- Pacote Aparência (Fábrica Abstrata) ---
package AppearanceFactory {
abstract class AppearanceFactory {
+ createBoardAppearance(): BoardAppearance
+ createPacManAppearance(): PacManAppearance
+ createGhostAppearance(color: String): GhostAppearance
+ createPointAppearance(): PointAppearance
+ createPowerPelletAppearance(): PowerPelletAppearance
+ createWallAppearance(): WallAppearance
+ createScoreAppearance(): ScoreAppearance
class SupermarketAppearanceFactory extends AppearanceFactory {
+ createBoardAppearance(): BoardAppearance
+ createPacManAppearance(): PacManAppearance
+ createGhostAppearance(color: String): GhostAppearance
+ createPointAppearance(): PointAppearance
+ createPowerPelletAppearance(): PowerPelletAppearance
+ createWallAppearance(): WallAppearance
+ createScoreAppearance(): ScoreAppearance
class OldWestAppearanceFactory extends AppearanceFactory {
+ createBoardAppearance(): BoardAppearance
+ createPacManAppearance(): PacManAppearance
+ createGhostAppearance(color: String): GhostAppearance
+ createPointAppearance(): PointAppearance
+ createPowerPelletAppearance(): PowerPelletAppearance
+ createWallAppearance(): WallAppearance
+ createScoreAppearance(): ScoreAppearance
class SpaceAppearanceFactory extends AppearanceFactory {
+ createBoardAppearance(): BoardAppearance
+ createPacManAppearance(): PacManAppearance
+ createGhostAppearance(color: String): GhostAppearance
+ createPointAppearance(): PointAppearance
+ createPowerPelletAppearance(): PowerPelletAppearance
+ createWallAppearance(): WallAppearance
+ createScoreAppearance(): ScoreAppearance
class CompanyAppearanceFactory extends AppearanceFactory {
+ createBoardAppearance(): BoardAppearance
+ createPacManAppearance(): PacManAppearance
+ createGhostAppearance(color: String): GhostAppearance
+ createPointAppearance(): PointAppearance
+ createPowerPelletAppearance(): PowerPelletAppearance
+ createWallAppearance(): WallAppearance
+ createScoreAppearance(): ScoreAppearance
interface Appearance {
+ draw()
interface BoardAppearance extends Appearance {
+ drawCell(cell: Cell)
interface PacManAppearance extends Appearance {
+ drawPacMan(pacMan: PacMan)
interface GhostAppearance extends Appearance {
+ drawGhost(ghost: Ghost)
interface PointAppearance extends Appearance {
+ drawPoint(point: Point)
interface PowerPelletAppearance extends Appearance {
+ drawPowerPellet(powerPellet: PowerPellet)
interface WallAppearance extends Appearance {
+ drawWall(wall: Wall)
interface ScoreAppearance extends Appearance {
+ drawScore(score: Score)
}
' --- Relacionamentos ---
Game --* Board
Game --* PacMan
Game --* [Link]
Game --* Score
Game -- InputHandler
Game -- [Link]
Board --* Cell
Cell --* Item
PacMan -- Direction
Ghost -- MoveStrategy
Ghost -- Direction
[Link] ..> [Link] :
uses
SupermarketAppearanceFactory --|> [Link]
OldWestAppearanceFactory --|> [Link]
SpaceAppearanceFactory --|> [Link]
CompanyAppearanceFactory --|> [Link]
BoardAppearance --|> [Link]
PacManAppearance --|> [Link]
GhostAppearance --|> [Link]
PointAppearance --|> [Link]
PowerPelletAppearance --|> [Link]
WallAppearance --|> [Link]
ScoreAppearance --|> [Link]
RedGhost --|> [Link]
RedGhost ..|> [Link]
PinkGhost --|> [Link]
PinkGhost ..|> [Link]
OrangeGhost --|> [Link]
OrangeGhost ..|> [Link]
WhiteGhost --|> [Link]
WhiteGhost ..|> [Link]
@enduml