An interactive Python tutorial designed to teach object-oriented programming concepts through hands-on exercises and practical examples. This educational project uses a subway system simulation to demonstrate key OOP principles including classes, objects, inheritance, and encapsulation.
Objectville provides a comprehensive learning experience for students and developers looking to master object-oriented programming in Python. The tutorial centers around a subway system model where learners can explore relationships between different classes, understand data flow, and practice implementing OOP design patterns.
The project is structured as an interactive learning environment that combines theoretical concepts with practical coding exercises, making it ideal for computer science courses, bootcamps, and self-directed learning.
- Python 3.6 or higher
- Basic understanding of Python syntax and fundamentals
- Clone the repository:
git clone https://github.com/michael-borck/objectville.git
cd objectville- Ensure Python is installed and accessible:
python --version- No additional dependencies are required - the project uses only Python standard library modules.
Run the main subway system simulation:
python Subway.pyThe tutorial is built around several key classes that work together:
Station Class
# Example of working with Station objects
from Station import Station
station = Station("Central Station", "CS001")
print(station.get_name())Connection Class
# Example of creating connections between stations
from Connection import Connection
connection = Connection(station1, station2, distance=5.2)Subway System
# Load and interact with the complete subway system
from Subway import Subway
from SubwayLoader import SubwayLoader
loader = SubwayLoader()
subway = loader.load_from_file("ObjectvilleSubway.txt")- Explore the Code Structure: Start by examining each class file to understand the relationships
- Modify Parameters: Change station names, distances, or connections in the data file
- Extend Functionality: Add new methods or properties to existing classes
- Run Simulations: Use the SubwayPrinter class to visualize different aspects of the system
Try modifying the subway system by adding a new station:
# Add this to your learning exercises
new_station = Station("University Campus", "UC001")
# Create connections to existing stations
# Update the subway system and observe the changesobjectville/
├── Station.py # Defines individual subway stations
├── Connection.py # Manages connections between stations
├── Subway.py # Main subway system class
├── SubwayLoader.py # Handles loading subway data from files
├── SubwayPrinter.py # Provides output formatting and display
├── ObjectvilleSubway.txt # Sample subway system data
├── output.txt # Generated output from exercises
└── README.md # Project documentation
Through this tutorial, you will learn:
- Class Design: How to structure classes with appropriate methods and attributes
- Object Relationships: Understanding composition and association between objects
- Data Encapsulation: Implementing proper getter/setter methods and data hiding
- File I/O: Reading structured data and creating objects from external sources
- System Architecture: Designing interconnected components that work together
This project was developed for educational purposes and is particularly suited for:
- Computer science students learning OOP concepts
- Python developers transitioning from procedural to object-oriented programming
- Instructors teaching object-oriented design principles
- Self-learners working through programming tutorials
The subway system can be customized by modifying the ObjectvilleSubway.txt file. The format follows a structured pattern that the SubwayLoader can parse to create the object network.
This is an educational project. If you're an instructor or student with suggestions for improvements:
- Fork the repository
- Create a feature branch for your enhancement
- Test your changes with the existing codebase
- Submit a pull request with a clear description of the educational value
This project is intended for educational use. Please refer to your institution's guidelines for academic projects and code sharing policies.