View Single Post
  #4 (permalink)  
Old 11-14-2007, 06:52 PM
darkgt darkgt is offline
Member
 
Join Date: Nov 2007
Posts: 5
darkgt is on a distinguished road
ok i redid it and this is what i got

Code:
public class Rectangle{ public static void main (String[]args){ Rectangle1 rectangle = new Rectangle1(); rectangle.setColor ("white"); rectangle.setHeight(1); rectangle.setWidth(1); System.out.println(rectangle.toString()); } } class Rectangle1 { private String color = "red"; private double height = 40; private double width = 4; private double area; private double perimeter; Rectangle1 () { } public double getHeight(){ return height; } public void setHeight(double height) { this.height = height; } public double getWidth(){ return width; } public void setWidth(double width){ this.width = width; } public String getColor(){ return color; } public void setColor(String color){ this.color = color; } //area and perimeter double getArea(){ return height * width; } double getPerimeter(){ return height* 2 + width* 2; } public String toString(){ return("the area is" + area + "the perimeter is" + perimeter + "\n" + "color is" + color); } }
but i cant get the answers to come out right now susposed to have color set as red but comes out as white. and the area and perimeter equal 0
Reply With Quote