Chapter 6. Interacting objects: Newton’s Lab

topics:

objects interacting with each other, using helper classes, using classes from the Java library

concepts:

collection, list, for-each loop, standard class library

In this chapter, we shall investigate more sophisticated interactions between objects in a world. As a start, we shall investigate one of the most universal interactions between objects anywhere: Gravity.

In this scenario, we are dealing with celestial bodies (such as stars and planets). We shall simulate the motion of these bodies through space, using Newton’s law of universal gravitation. (We now know that Newton’s formulas are not quite accurate, and that Einstein’s theory of general relativity describes the motions of planets more precisely, ...

Get Introduction to Programming with Greenfoot: Object–Oriented Programming in Java™ with Games and Simulations, First Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.