2.2. Building an Application
Before going any further with our spaceship example, we are going to build an application framework so that you can run and experiment with the code. We are going to do this by creating a SpaceGame class:
public class SpaceGame { private JavaSpace space; public SpaceGame(JavaSpace space) { this.space = space; } public static void main(String[] args) { JavaSpace space = SpaceAccessor.getSpace(); SpaceGame game = new SpaceGame(space); } }
This class contains a constructor that takes one parameter, an object that implements the JavaSpace interface, and assigns it to the local variable space. It also contains a static main method.
When we run our application, the static main method is executed, which first makes use ...
Get JavaSpaces™ Principles, Patterns, and Practice 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.