下面是我做的一道作业题,我想大家把你们的排版方式给我看哈,我不知道该怎么排,不排好的话以后代码看起来就很杂乱...
class point{
 protected int x,y;
 public point(){
   x=0;
   y=0;
}
public point(int x,int y){
    this.x=x;
    this.y=y;
}
public int getX(){
  return x;
}public int getY(){
  return y;
}public void setX(int x){
  this.x=x;
}public void setY(int y){
  this.y=y;
}
}class Circle extends point{
    protected int radius;
    public Circle(int r,int x,int y){
         super(x,y);
         radius=r;
        }
    public Circle(){
       radius=0;
      }
    public Circle(int radius){
        this.radius=radius;
     }
     public int getRadius(){
        return radius;
   }
void area(){
   System.out.println("圆的面积:"+ Math.PI*radius*radius);
  }
double A(){
return Math.PI*radius*radius;
  }
}class Cylinder extends Circle{
      protected int height;
  Cylinder(int x,int y,int radius,int height){
      super(x,y,radius);
      this.height= height;

  Cylinder(){
     height=0;
}
  Cylinder(int H){
     height=H;

   int getHeight(){
    return height;
   }
void volume(){
  System.out.println("圆zhu的体积:"+A()*height);
 }
}
 class demo{
 public static void main(String args[]){         Cylinder r1=new Cylinder(10,10,10,10);
         System.out.println("中心坐标:"+r1.x+","+r1.y);
         System.out.println("半径:"+r1.radius);
         System.out.println("高:"+r1.height);
         r1.volume();
  }
}

解决方案 »

  1.   

    建议你用Eclipse,用Ctrl+Shift+F,自动调节代码的格式安排,看起来明白的多, 很方便
      

  2.   

    class classname
        {
            mothed mothedname()
                {
                  ........
                }
        }
    这样应该更清晰些
      

  3.   

    个人习惯而已~class ClassName{//ClassName第一个字母大写
      private int aaaBbb;//变量,匈牙利命名法
      
      public void methodName(){//methodName首字母小写,并且整体能看出来该方法的意义的
        //........
      }
    }
      

  4.   

    sorry:private int iAaaBbb;//变量,匈牙利命名法