Question
There are three main types of object in the solar system. There are suns, planets and moons. (Thereare others too, like comets and asteroids and
There are three main types of object in the solar system. There are suns, planets and moons. (Thereare others too, like comets and asteroids and Klingons but lets keep it simple for now!). Note that these are similar in many ways - they will all have a name, colour, diameter and location, but have different behaviour. Suns don't move, planets orbit the sun and moons orbit planets.
Making use of the concepts weve been discussing in lectures, refactor the program you wrote last week to create the most elegant, reusable and extensible solution you can. More specifically:
Create a class to represent a point (a location).
Create class(es) to represent at least the three types of solar object listed above.
Your classes should model the location, orbital velocity, size, colour etc. for each object in
your solar system.
Write method called move that updates the modelled position of an object according to its
velocity. You can assume the move method will be called periodically...
Writesuitableconstructorsforeachofyourclasses.
Take care to structure your classes such that they contain little or no repeated variables or
code.
Write a suitable main method that uses your new classes and methods to render an
animated model of the inner solar system (the sun, Mercury, Venus, Earth, Mars and
associated moons).
Think carefully about how you will store instances of your classes and show how
polymorphism can help to make code simpler and more elegant.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started