Git Product home page Git Product logo

solar-system's Introduction

Solar System

Let's make a planetary system!

Learning Goals

  • Practice creating custom classes
  • Create an object which contains a collection of other objects
  • Practice creating instance methods

Wave 1

Primary Requirements

  • Create a SolarSystem class with an @planets instance variable.
  • Create an initialize method which should take a collection of planet names and store them in an @planets instance variable.
  • Create a method to add a planet to the list.
  • Create a method which will return not print a list of the planets as a String in this style:
1.  Mercury
2.  Venus
3.  Earth
4.  Mars
5.  Jupiter
6.  Hoth
  • Write code to test your SolarSystem
  • Instead of Strings for planets, modify SolarSystem's initialize method to take a list of hashes where each planet is sent as a hash with at least 5 attributes.

Optional Enhancements

  • Give each planet a year_length attribute which is the length of time the planet takes to go around it's star.
  • Give each planet a distance_from_the_sun attribute
  • Write a program that asks for user input to query the planets:
    • First, ask the user to select a planet they'd like to learn about.
    • Present the user with a list of planets from which they can choose. Something like:
      • 1. Mercury, 2. Venus, 3. Earth, 4. Secret Earth, 5. Mars, 6. Jupiter, ... 13. Exit
    • Provide the user with well formatted information about the planet (diameter, mass, number of moons, primary export, etc.)
    • Then ask the user for another planet.

Wave 2

Primary Requirements

  • Create a Planet class which will represent a planet.
    • Add an initialize method which takes several arguments and uses them to set the class' instance variables.
    • Create a method that returns the Planet's attributes in an easy to read fashion.
    • Create reader methods to give a user access to read the instance variables.
  • Make your SolarSystem class take an array of Planets instead of hashes.
    • When printing the planet list or planet details, it should call the corresponding method in Planet.

Optionals

  • Create a method, outside any class, which creates a planet from user input.

Wave 3

Primary Requirements

  • Create an interface where the user can interact with the solar system and be able to select a planet and view information about it.
  • Allow your user to add their own planet.

Optional Enhancements

  • Ensure that the each planet has a @distance_from_the_sun attribute. Using this data, add a method to determine the distance from any other planet (assuming planets are in a straight line from the sun)
  • Give your solar system an age (in earth years).
  • Define a method that returns the local year of the planet based on it's rotation since the beginning of the solar system

solar-system's People

Contributors

cheezitman avatar hamled avatar jnf avatar kariabancroft avatar tildeee avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.