| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 535 人关注过本帖
标题:各位大虾帮帮小弟,看看这个程序吧!
取消只看楼主 加入收藏
ted19910129
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2011-3-18
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:0 
各位大虾帮帮小弟,看看这个程序吧!
abstract class Student
输出信息.zip (20.97 KB)

{
      String name;
    String type;
    float score;
    String level;

    abstract String GetName();
    abstract String GetType();
    abstract float GetScore();
    abstract String GetLevel();
};
class Undergraduate extends Student{
          String GetName(String x){
    this.name = x;

   
    }
    String GetType(String y){
    this.type = y;
   
    }
    float GetScore(float a){
        this.score = a;
   
   
    }
    String GetLevel(){
        if(this.score>=85&&this.score<100)
            level = "excellent";
        if(this.score<85&&this.score>=75)
            level = "good";
        if(this.score<75&&this.score>=65)
            level = "middle";
        if(this.score<65&&this.score>=60)
            level = "poor";
        if(this.score<60)
            level = "fail";
   
   
    }
    public String toString(){
        return "Name:"+name+"\nType:"+type+"\nScore:"
        +score+"\nLevel:"+level+"\n";
   
   
   
   
   
    }
};
class Postgraduate extends Student
{     
          String GetName(String x){
        this.name = x;
   
    }
    String GetType(String y){
        this.type = y;
    }
    String GetScore(float a){
        this.score = a;
   
    }
    String GetLevel(){
        if(this.score>=90&&this.score<=100)
            level = "excellent";
        if(this.score<90&&this.score>=80)
            level = "good";
        if(this.score<80&&this.score>=70)
            level = "middle";
        if(this.score<70&&this.score>=60)
            level = "poor";
        if(this.score<60)
            level = "fail";
   
   
    }
    public String toString(){
        return "Name:"+name+"\nType:"+type+"\nScore:"
        +score+"\nLevel:"+level+"\n";
   
   
    }
};

public class StudentDemo
{
    public static void main(String[] args)
    {
        Undergraduate a = new Undergraduate();
        a.GetName("Tom Smith");
        a.GetType("Undergraduate");
        a.GetScore(85.3f);
        a.GetLevel();
        System.out.println("As follows,this is some exam information of an undergraduate");
        a.toString();
        
        Postgraduate b = new Postgraduate();
        b.GetName("Jerry Zhang");
        b.GetType("Postgraduate");
        b.GetScore(91.3f);
        b.GetLevel();
        System.out.println("As follows,this is some exam information of a postgraduate");
        b.toString();
    };
};
//输出提示没有覆盖抽象方法,可我找不到错误啊,我把输出的dos窗口传上去了,请大家帮我看一下吧,谢谢


[ 本帖最后由 ted19910129 于 2011-3-18 10:31 编辑 ]
搜索更多相关主题的帖子: abstract 
2011-03-18 09:31
快速回复:各位大虾帮帮小弟,看看这个程序吧!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028698 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved