CNS 1400: Lab #27


The objective of this lab is to learn how to create an array of objects from data stored in a file.


One of the key tasks to be done in the final project for this course will be to read some data from a file and use that data to create an array of Employee objects. This lab will give you some practice reading data from a file and using the data to create an array of objects

The Problem

If you have not already done so, watch the video Creating an Array of Objects. After watching the video create a new Console project. Copy this code for the Box class into your project:

class Box
   private int height;
   private int width;
   private int depth;
   public Box(int p1, int p2, int p3)
      height = p1;
      width = p2;
      depth = p3;
   public int GetVolume()
      return (height * width * depth);

Now using the ideas and the fragments of code presented in the video, complete the program that reads data from a file, creates a set of Box objects from that data, and store the references to these objects in an array. After all of the data in the file has been read, display the volume of each box. Use the test data shown in the video. Your program should assum that the file to be read is in the user's Documents folder.

Build test and your program to make sure it meets the specifications provided in this lab.

File(s) to Submit:

Place your complete project folder in a zip file and name the zip file For example, I would name my file Submit this assignment as Lab #27 on Canvas.


Description Points possible Your points
Assignment meets the submission guidelines.
o All source code files contain a complete file prologue
o All methods have a complete method prologue
o Source code files contain declaration that you did not copy code
o Project has been properly submitted to Canvas
o Code meets style guidelines
The program works correctly and meets all requirements. 3  
Total 5