Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Architecture #72

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added doc/UMLdiagrams/UI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions doc/UMLdiagrams/UI.uml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@startuml

class UI
class SimulationEventHandler
SimulationEventHandler --o UI

class AbstractFlagHandler
AbstractFlagHandler o-- AbstractFlagHandler
class TerminalFlagRequest
AbstractFlagHandler -- TerminalFlagRequest
class InitialOrganismCount extends AbstractFlagHandler
class GridSize extends AbstractFlagHandler

@enduml
Binary file added doc/UMLdiagrams/entities.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions doc/UMLdiagrams/entities.uml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@startuml

interface Entity
class EntityFactory
EntityFactory -- Entity

class AbstractEnvironmentPieces implements Entity
class Rock extends AbstractEnvironmentPieces
class Water extends AbstractEnvironmentPieces

class AbstractOrganism implements Entity

class AbstractPlant extends AbstractOrganism
class Grass extends AbstractPlant
class Carrot extends AbstractPlant

class AbstractAnimal extends AbstractOrganism
class Rabbit extends AbstractAnimal
class Fox extends AbstractAnimal

@enduml
Binary file added doc/UMLdiagrams/incidents.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions doc/UMLdiagrams/incidents.uml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@startuml

Interface Incident
class IncidentFactory
Incident -- IncidentFactory

class AbstractTimeIncident implements Incident

class AbstractWeather extends AbstractTimeIncident
class Sunshine extends AbstractWeather
class Rain extends AbstractWeather
class Clouds extends AbstractWeather
class Snow extends AbstractWeather

class AbstractSeasons extends AbstractTimeIncident
class Summer extends AbstractSeasons
class Autumn extends AbstractSeasons
class Winter extends AbstractSeasons
class Spring extends AbstractSeasons

class AbstractRandomIncident implements Incident

class AbstractDisaster extends AbstractRandomIncident
class Earthquake extends AbstractDisaster
class Avalanche extends AbstractDisaster
class Flood extends AbstractDisaster
class Tornado extends AbstractDisaster

@enduml
Binary file added doc/UMLdiagrams/simulation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions doc/UMLdiagrams/simulation.uml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@startuml

class Simulation
class Map
Simulation --o Map

@enduml
29 changes: 29 additions & 0 deletions doc/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Architecture

## Overview

This document outlines the architecture of our project. Each section represents a separate package within the program.

## UI

The UI package contains everything needed for a user to interact with the program. The UI class contains the main method for the program which simply runs a simulations when called. It contains an instance of the SimulationEventHandler class which handles anything that happens in the simulation that the UI might need to output. It acts a bridge between the UI and the simulation.

The AbstractFlagHandler class is a template for flag handlers which will check for flags when the program is run. An instance of AbstractFlagHandler contains another instance of the same class which is the successor to it in a chain of responsibility. The InitialOrganismCount class will check for the flag giving the initial organism count while GridSize will do the same for the size of the map in the simulation. TerminalFlagRequest simply represents the whole set of terminal flags given as a single object.

![UI](./UMLdiagrams/UI.png)

## Simulation

The architecture of the Simulation package is rather simple. The simulation class contains all of the logic relating to changing the environment at specified time intervals. It's the main driver of the program. Simulation also contains an instance of the Map class which represents where various living and nonliving things are in the environment.

![Simulation](./UMLdiagrams/Simulation.png)

## Entities

The Entities package contains classes relating to both living and nonliving things that may occupy space in the simulated environment. The Entity interface is an interface to allow the Map class from the Simulation package to be able to contain a given class. AbstractEnvironmentPieces implements Entity and is an abstract class representing nonliving things, and Rock and Water are concrete extensions of this class.

AbstractOrganism implements Entity and is an abstract class representing living things. AbstractPlant extends AbstractOrganism and represents plants in the environment. Grass and Carrot are concrete extensions of AbstractPlant. AbstractAnimal extends AbstractOrganism and represents animals in the environment. Rabbit and Fox are concrete extensions of AbstractAnimal.

Finally, EntityFactory is a class that creates an instance of Entity based on certain specifications. It can create a direct instance of any subclass of Entity that has previously been registered with it. EntityFactory uses the singleton design pattern, so there will only ever be one entity factory in the program.

![Entities](./UMLdiagrams/Entities.png)