gradstudent.java

来自「java源程序 对初学者有很大的帮助 从简单到复杂」· Java 代码 · 共 38 行

JAVA
38
字号
//********************************************************************
//  GradStudent.java       Author: Lewis/Loftus
//
//  Represents a graduate student with financial support. Used to
//  demonstrate inheritance.
//********************************************************************

public class GradStudent extends Student
{
   private String source;
   private double rate;

   //-----------------------------------------------------------------
   //  Sets up the gradate student using the specified information.
   //-----------------------------------------------------------------
   public GradStudent (String studentName, int courses,
                       String support, double payRate)
   {
      super (studentName, courses);

      source = support;
      rate = payRate;
   }

   //-----------------------------------------------------------------
   //  Returns a description of this graduate student as a string.
   //-----------------------------------------------------------------
   public String toString()
   {
      String result = super.toString();

      result += "\nSupport source: " + source + "\n";
      result += "Hourly pay rate: " + rate;

      return result;
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?