I can't figure out for the life of me why the names of the square and rectangle won't show up....can anyone help?
public class Square extends NamedShape implements Shape
{
public void Length()
{
System.out.printf("Please Enter Length Value: ", this.getLength());
}
public Square(String name) {
super(name);
System.out.printf("Shape:", this.getName());
}
}
and
public class Rectangle extends NamedShape implements Shape
{
@Override
public void Length()
{
System.out.printf("Please Enter Length Value: ");
}
public Rectangle(String name) {
super(name);
System.out.printf("Shape:", this.getName());
}
}
and finally:
public class AreaFinder {
private Shape[] shapes;
private int population;
public AreaFinder() {
shapes = new Shape[100];
}
public void populate() {
addShape(new Square("Square"));
addShape(new Rectangle("Rectangle"));
}
private void addShape(Shape a) {
shapes[population++] = a;
}
public static void main(String[] args) {
AreaFinder shapes = new AreaFinder();
shapes.populate();
}
public void LengthFinder()
{
System.out.printf("Length Values Called");
for(int i = 0; i < population; i++)
{
shapes[i].Length();
}
}
}
public class NamedShape
{
private String name;
public double length;
double newlength;
double side_length;
public String getName() {
return name;
}
public Double getLength()
{
return newlength;
}
public NamedShape(double newlength)
{
this.length = newlength;
System.out.printf("\t");
}
public NamedShape(String name) {
this.name = name;
System.out.printf("\t");
}
}