为办公室写一个星期的日记

时间:2011-05-03 15:07:24

标签: java

我正在为牙医写一个星期的日记。牙医每天工作8到5次,但休息一小时。牙医执行4个程序:

  • 常规程序需要15分钟。
  • 缩放需要30分钟。
  • 填充需要45分钟,
  • 提取需要90分钟。

日记应该能够预约,取消现有的预约,并检查是否在特定时间安排预约。以下是我到目前为止所写的一个示例。我决定为4个不同的过程创建一个类,然后有一个过程类,在其构造函数中包含所有4个过程。不过,我不知道怎么把程序写入日记。

// a regular procedure class that takes 15 minutes
public class RegularProcedure {
       // the duration period of a regular procedure is 15
   private  int []procedure;
    static final int  times=15;

     public RegularProcedure(){

         procedure=new int[times];
         for(int i=0; i <procedure.length;i++){
             procedure[i]=i;
         }
     }
}

// a scaling class that takes 30 minutes
public class Scaling {
    private int []scaling;
    static final int time=30;


    public Scaling(){

        scaling =new int[time];
        for (int i=0;i<scaling.length;i++){
            scaling[i]=i;
        }
    }
}

// a filling procedure class that taked 45 mins to complete a procedure 
public class Filling {
    private int[]filling;
    static final int time=45;


    public Filling(){

       filling=new int[time];
       for(int i=0;i<filling.length;i++){
           filling[i]=i;
       }
    }
}

// an extraction class that takes 90 minutes 
public class Extraction {
  private int[]extraction;
 static final int time=90;


 public Extraction(){

       extraction = new int[time];
       for(int i=0; i<extraction.length;i++){
           extraction [i]=i; 
       }
   }
}

// a procedure class that contains that contains the four procedures performed by d dentist
public class Procedures {
    RegularProcedure a;
    Scaling b;
    Filling c;
     Extraction d;

    public Procedures(){
        a= new RegularProcedure();
        b= new Scaling();
        c= new Filling();
        d= new Extraction();
    }
}

public class Diary {
  private int [][]diary;
  int []diaryday;
   Procedures y;

   //a diary constructor for a week
   public Diary(){

       diary=new int[5][540];
       y=new Procedures();
     for (int i=0; i<diary.length;i++) {
         for(int j=0;j <diary[i].length;j++){
             diary[i][j]= 0; 
         }
     }
   }

   /* method to determine if dentist office is open or on 
    * break
    */
     public Boolean isOnBreak(int time){
         if(time>=0 &&time<240 ||time>=300 &&time<540){
             return false;}
         else 
             return true;
     }    
}

如何将程序纳入日记?

1 个答案:

答案 0 :(得分:0)

一个建议,重新思考整个事情。但首先,学习一些基本的OO编程。您的不同程序应该是Procedure的子类。了解“有一个”和“是一个”之间的区别。

http://download.oracle.com/javase/tutorial/java/concepts/index.html

http://download.oracle.com/javase/tutorial/java/IandI/index.html