The Woodfinder Class

For this project you are going to create a Wood Object and the WoodFinder Object. The Wood object will have a depth, length and width (integers). You should have a constructor and 3 accessors for it.

Next you will have a WoodFinder class.

import java.util.*;

public class woodFinder
private int ct = 0;

public void reader() throws IOException
{FileReader fr = new FileReader("woodfile.txt");
BufferedReader br = new BufferedReader(fr);
String d,l,w;
int depth,length,width;
while ((d = br.readLine()) != null) // while not end of file
l = br.readLine();
w = br.readLine();
depth= Integer.parseInt(d);
length= Integer.parseInt(l);
width= Integer.parseInt(w);

There are a couple of things different about this file reader. It read until it hits the end of file, not a certain amount of times.

In the Woodfinder class have an array with a length of 100 of Wood. You will then read in from a file, create your wood onbject and put it in to the array. Note: for this project you will not have the array's length objects, you will have ct of them.

Next - open the data.txt file Here. Save it as woodfile.txt into the same folder where your Woodfinder and Wood classes is (your file will be in the folder you created when you opened the new project).

Then we will write some methods
  1. public void printWoodPieces() // all 3 dimensions on same line
  2. public int countWoodPiecess() // how many pieces in all
  3. public int longestPieceofWood() // what is longest length
  4. public int ShortestPieceofWood() // what is shortest
  5. public void printMatch(int d,int w)// this method will print out the piece of wood that has the same depth // it will also have at least the same width and length as asked for, and it will print out // the piece that meets the requirements and use the least amount of total wood (square inches) public String toString() // returns dimensions

When you get it working write a client program that tests your methods, and 6 different printMatches