Homework #9:

  1. I created a class, datum.py and assigned x, y, and z values as specified. I set the accessor functions to return self.x, self.y, and self.z. I changed the move, undraw, and setFill functions to check if the self.circle was not equal to None, the move function moved the point and the undraw function undrew the point. If self.cirle was equivalent to None, the draw function drew the data point, otherwise, the function would undraw, move, and draw the point. The read and write functions were coded to read three values in a line from a file and write three values to a file, respectively. In DataCollection skeleton (skeleton.py), I coded the write function so it wrote a collection of data to a file. THe move function shifts the display on the graph, and the add function adds a piece of data to the collection of data.
  2. This is an image of the Datum class.

  3. This is an image of the Data Collection class.

  4. The fields are created using a random assignment within a range, and then parameters of the previously generated numbers are used to define the other pieces of data. In the project, once x, y, and z are assigned, they are combined into one point and appended to the collection of data, as is shown below.
  5. To access the fields in an object, the fields are first written to a file, here, testdata.txt. Then, the method reads the file until it had read all of the data.