Skip to content

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OOP Exercises β€” Python & Java

A collection of object-oriented programming exercises implemented in both Python and Java, developed during my second semester of Computer Science and AI Engineering at Universidad Sergio Arboleda (Fundamentos de Software).

Each exercise includes:

  • πŸ“ A UML class diagram β€” the design comes before the implementation
  • β˜• A Java implementation (statically typed, extends / implements)
  • 🐍 A Python implementation (ABC module simulating interfaces)
  • πŸ“ A short README explaining the concept applied

Why design first?

Sketching the UML diagram before writing any code forces you to define the relationships between classes β€” inheritance, interface contracts, cardinality β€” before implementation details get in the way. It also makes it obvious when a language-specific implementation is inconsistent with the original design, which is exactly the kind of thing this repo is meant to demonstrate.

Concepts covered

  • Abstract classes (the "is-a" relationship β€” shared state and behavior)
  • Interfaces (the "can-do" relationship β€” a contract every implementer must fulfill, regardless of where it sits in the inheritance tree)
  • Polymorphism (treating different concrete classes uniformly through a shared abstract type or interface)
  • Encapsulation

See docs/key-concepts.md for a deeper explanation of how these ideas map between Java and Python.

Exercises

# Domain Classes
01 Private transportation Transporte, Conducible, Carro, Moto, Bicicleta
02 Video game characters Personaje, Atacante, Guerrero, Mago, Arquero
03 Streaming content Contenido, Reproducible, Pelicula, Serie, Documental
04 Food preparation Alimento, Preparable, Hamburguesa, Pizza, Ensalada
05 Animals Animal, Sonoro, Perro, Gato, Vaca
06 Bank accounts CuentaBancaria, Operable, CuentaAhorro, CuentaCorriente
07 Geometric shapes Figura, Calculable, Circulo, Rectangulo, Triangulo
08 Electronic devices Dispositivo, Controlable, TV, Radio, Celular
09 Professionals Persona, Profesional, Medico, Ingeniero, Profesor
10 Public transportation TransportePublico, Transportador, Bus, Metro, Taxi

Each exercise follows the same pattern (abstract class + interface + polymorphism) applied to a different domain, and deliberately implements a different concrete subclass in each language.

Extra: theoretical design cases

docs/theoretical-cases.md contains 10 additional design-only case studies (no code) exploring relationships that go beyond inheritance and interfaces β€” aggregation, composition, and association β€” across domains like a library system, a payment platform, and a hospital management system.

Structure

oop-exercises/
β”œβ”€β”€ exercises/
β”‚   β”œβ”€β”€ 01-transporte-privado/
β”‚   β”‚   β”œβ”€β”€ diagram.puml
β”‚   β”‚   β”œβ”€β”€ Main.java
β”‚   β”‚   β”œβ”€β”€ main.py
β”‚   β”‚   └── README.md
β”‚   β”œβ”€β”€ 02-personajes-videojuego/
β”‚   └── ...
└── docs/
    β”œβ”€β”€ key-concepts.md
    └── theoretical-cases.md

Stack

  • Java (JDK)
  • Python 3 (abc module)
  • PlantUML for diagrams

About

🎈UML-driven OOP exercises in Java & Python β€” inheritance, interfaces, and polymorphism applied across 10 real-world domains, plus 10 extended design cases covering aggregation and composition.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages