City Grid Planner Java
A Java command-line city planning simulator that loads a grid from a text file and evaluates whether structures can be built on different terrain and zoning conditions.
The project was developed as an Object-Oriented Software Engineering assignment and later cleaned for portfolio presentation. It focuses on object-oriented modelling, grid parsing, zoning validation, build-cost calculation, configurable city-building approaches, error handling, and logging.
Reviewer Quick Scan
- What it demonstrates: grid parsing, zoning-rule modelling, construction validation, cost calculation, console UX, and Gradle-based Java project structure.
- Best files to inspect first: docs/design-notes.md, docs/class-diagram.png, and src/main/java/edu/curtin/app/.
- How to verify it: run the app with data/sample-grid.txt, then compare the behavior with docs/sample-output.txt.
Features
- Load city grid data from a text file
- Represent a city as a two-dimensional grid of terrain squares
- Support terrain types such as flat, swampy, and rocky land
- Parse zoning rules including heritage, height limits, flood risk, and contamination
- Test whether a single structure can be built at a selected grid location
- Calculate construction cost based on terrain, foundation, material, floors, and zoning constraints
- Simulate full-city build attempts using configurable build approaches
- Display a text-based visualisation of the city grid and build results
- Handle invalid input and file parsing errors with logging support
Tech Stack
| Category | Technology | |---|---| | Language | Java | | Build Tool | Gradle | | Testing/Linting | JUnit 5, PMD | | Interface | Command-line menu | | Logging | Java logging |
Project Structure
city-grid-planner-java/
|-- src/main/java/edu/curtin/app/
| |-- App.java # CLI entry point
| |-- builder/ # Structure and city build strategies
| |-- model/ # Grid, square, terrain, and structure models
| |-- model/zoning/ # Zoning-rule classes
| `-- util/ # Parsing, visualisation, logging helpers
|-- data/
| `-- sample-grid.txt # Sample input grid
|-- docs/
| |-- class-diagram.png
| |-- design-notes.md|-- build.gradle |-- settings.gradle |-- oose-pmd-rules.xml |-- logging.properties -- README.md
## How to Run
### Option 1: Run with Gradle
For macOS/Linux:
chmod +x ./gradlew ./gradlew run --args="data/sample-grid.txt"
For Windows:
.\gradlew.bat run --args="data/sample-grid.txt"
### Option 2: Compile with Java directly