Skip to main content

An object-oriented fantasy solar system model (Python port of the Java original).

Project description

python_solar-system

An object-oriented model of a (fantasy) solar system - a Python re-imagining of the original java_solar-system project, preserving its domain principles while expressing them idiomatically in Python.

Domain principles (carried over from the Java version)

Java Python Principle
Planet.java solar_system/planet.py A planet has a name, mass (Earth masses) and distance (AU); it derives its orbital period from Kepler's third law T = √(a³).
getters/setters over fields validated @property accessors Encapsulation - values are validated on assignment and reported rounded to 3 decimals.
SolarSystem.java solar_system/solar_system.py A named, ordered collection of planets with an overloaded add_planet.
overloaded addPlanet type-dispatching add_planet Accepts either a Planet or (name, mass, distance).
FantasySolarSystem.java solar_system/cli.py Interactive driver: prompts for a system name, reads planet names until done, assigns random mass/distance in [0, 50), prints each planet, then a formatted table.

Layout

python_solar-system/
├── solar_system/
│   ├── __init__.py        # package exports (Planet, SolarSystem)
│   ├── planet.py          # Planet domain object
│   ├── solar_system.py    # SolarSystem aggregate (sequence protocol)
│   ├── cli.py             # interactive driver + table formatting
│   └── __main__.py        # `python -m solar_system`
├── tests/                 # pytest suite
├── pyproject.toml
└── README.md

Running

From inside python_solar-system/:

# Run the interactive fantasy builder
python -m solar_system

# Or, after `pip install -e .`
fantasy-solar-system

Example session:

Enter the name of the solar system:Andromeda
Now enter planet names - type 'done' to finish
Enter name: Krypton
Planet Krypton has a mass of 12.34 Earths, is 5.6AU from its star, and orbits in 13.25 years
Enter name: done

Name       Mass                 Distance             Period (years)
Krypton    12.34                5.6                  13.25

Programmatic use

from solar_system import Planet, SolarSystem

system = SolarSystem("Sol")
system.add_planet("Earth", mass=1.0, distance=1.0)
system.add_planet(Planet("Mars", 0.107, 1.524))

for planet in system:               # SolarSystem is iterable
    print(planet.name, planet.orbital_period)

print(system)                        # full multi-line summary

Tests

pip install -e ".[test]"
pytest

Origin

This codebase began as an artifact of a conversation about Self-Realization as the key to avoiding failure — recorded with a YouTube creator whose work reaches roughly 14k monthly views. Porting the 2017 Java original to a clean, test-backed Python design was the practical companion to that conversation: a small, deliberate act of building something true to its own first principles.

Credit

Domain and behaviour derived from the original Java project, © 2017 Richard A. Famoroti.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

famoroti_solar_system-1.0.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

famoroti_solar_system-1.0.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file famoroti_solar_system-1.0.0.tar.gz.

File metadata

  • Download URL: famoroti_solar_system-1.0.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for famoroti_solar_system-1.0.0.tar.gz
Algorithm Hash digest
SHA256 31b75d0e5c1aadf95fa57a8113441cc130e0ab89a87b8e691ae2a0dd669d908d
MD5 c928caf349bd544dfc70f72b294c32dd
BLAKE2b-256 fdaa2342366caac8d89060a68e355458730f32b08d95735f882cd23509ca06e3

See more details on using hashes here.

File details

Details for the file famoroti_solar_system-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for famoroti_solar_system-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 450ba348dc8cd532332c603b2f983e8cacb5b85564491aa2b5eea55b2e7e01ab
MD5 814a708c527151e9e5d24fd5c05b5c0b
BLAKE2b-256 dc51a925f3c441f8d7901235041568f040ddc3effc36e827d6e8ea17c9990956

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page