CS 231 Lab 2: Constellation data

We saw in lecture today how to create two new types of composite data:

  1. class types, which allow several "variables" of different types to be gathered together, with the pieces accessed by name; for these we must define a named template called a class, and save the definition in a file through the upper window of Dr Java.
  2. array types, which allow several nameless "variables" of the same type to be gathered together in a sequence, with the pieces (or elements) accessed by index number; for these we simply write the element type followed by square brackets (as in int [] or String []).

For this assignment, you will write a description of a constellation ... not all the details of star names, connection lines, etc., but rather just the locations and "magnitudes" (apprent sizes or brightnesses) of the stars.

You will write a definition for a class Star so that each star contains three values: double values for x and y coordinates and an int magnitude. You should then write a definition for an array of stars, filling in the elements with new-ly created stars.

You can get the data for your constellation from a picture which you can find in a book or on the web; you might like to use a constellation which has some special meaning to you. Measure the coordinates as distances from one of the corners in the horizontal (x) and vertical (y) directions, and use small ints representing rough relative sizes for the stars' magnitudes.

Once you have the data itself and the class definition for stars, you can put the data into a text file in this format:

Star[] bear = { new Star ( 12.5, 11.3, 4) ,
                new Star ( 10.1,  6.0, 3) ,