| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 523 人关注过本帖
标题:谁能帮帮我呀
取消只看楼主 加入收藏
ted19910129
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2011-3-18
结帖率:50%
收藏
 问题点数:0 回复次数:1 
谁能帮帮我呀
输出信息.zip (19.17 KB)
abstract class Student
{
      String name;
    String type;
    float score;
    String level;
    abstract String GetName();
    abstract String GetType();
    abstract float GetScore();
    abstract String GetLevel();
 };
 interface I1{
    public String GetLevel();
 
 
 
 
 }
 class UnderI1 implements I1
 {         
            String GetLevel(float score){
        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";
   
   
    }
 };
 class PostI1 implements I1

 {
        String GetLevel(float score){
        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";
   
   
    }
 };
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;
   
   
    }
   
   
    }
    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;
   
    }
   
    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();
        I1 c = new UnderI1();

        a.GetName("Tom Smith");
        a.GetType("Undergraduate");
        a.GetScore(85.3f);
        a.level = c.GetLevel(a.score);
        System.out.println("As follows,this is some exam information of an undergraduate");
        a.toString();
        
        Postgraduate b = new Postgraduate();
        c = new PostI1();
        b.GetName("Jerry Zhang");
        b.GetType("Postgraduate");
        b.GetScore(91.3f);
        b.level = c.GetLevel(b.score);
        System.out.println("As follows,this is some exam information of a postgraduate");
        b.toString();
    };
};
//我不知道为什么toString()没法用,求解!!!!!!!!!小弟感激不尽
2011-03-18 10:28
ted19910129
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2011-3-18
收藏
得分:0 
回复 楼主 ted19910129
请帮我看看我传的输出信息
2011-03-19 17:10
快速回复:谁能帮帮我呀
数据加载中...
 
   



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

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