class Rectangle
{
protacted int width;
int height;
public Rectangle(int w,int h)
{
width=w;
height=h;
}
public void drawRect()
{
for(int i=width;i>0;i--)
System.out.println("#");
System.out.println();
for(int i=heigth-2;i>0;i--)
{
System.out.print("#");
for(int j=width-2;j>0;j--)
System.out.println("");
System.out.print("#\n");
}
for(int i=width;i>0;i--)
System.out.println("#");
System.out.print("\n");
}
}
class MakeRectangle
{
public static void main(String args[])
{
int w=Integer.valueOf(args[0]).intValue();
int h=Integer.valueOf(args[1]).intValue();
Rectangle rect=new Rectangle(w,h);
rect.drawRect();
}
}
和书上的一样可就是不出来。请各位帮个忙!谢谢!!
{
protacted int width;
int height;
public Rectangle(int w,int h)
{
width=w;
height=h;
}
public void drawRect()
{
for(int i=width;i>0;i--)
System.out.println("#");
System.out.println();
for(int i=heigth-2;i>0;i--)
{
System.out.print("#");
for(int j=width-2;j>0;j--)
System.out.println("");
System.out.print("#\n");
}
for(int i=width;i>0;i--)
System.out.println("#");
System.out.print("\n");
}
}
class MakeRectangle
{
public static void main(String args[])
{
int w=Integer.valueOf(args[0]).intValue();
int h=Integer.valueOf(args[1]).intValue();
Rectangle rect=new Rectangle(w,h);
rect.drawRect();
}
}
和书上的一样可就是不出来。请各位帮个忙!谢谢!!
for(int i=heigth-2;i>0;i--)----->for(int i=height-2;i>0;i--)
笔误拉