| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 522 人关注过本帖
标题:谁能帮帮我呀
只看楼主 加入收藏
ted19910129
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2011-3-18
结帖率:50%
收藏
 问题点数:0 回复次数:5 
谁能帮帮我呀
输出信息.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
w123012306
Rank: 9Rank: 9Rank: 9
来 自:湖南
等 级:蜘蛛侠
威 望:4
帖 子:307
专家分:1180
注 册:2010-4-22
收藏
得分:0 
模糊

楼上,楼下的一定要幸福开心哦!
2011-03-19 12:59
ted19910129
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2011-3-18
收藏
得分:0 
回复 楼主 ted19910129
请帮我看看我传的输出信息
2011-03-19 17:10
lampeter123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:54
帖 子:2508
专家分:6424
注 册:2009-1-30
收藏
得分:0 
搞清楚抽像类与接口的概念后,再重新设计你的类吧, 你的程序可以再简洁些的
get 和set方法不能混合在一起: get方法没有参数,但要有返回类型, set方法有一个参数。没有返回类型

你的优秀和我的人生无关!!!!
    
    我要过的,是属于我自己的生活~~~
2011-03-22 09:08
lisypro
Rank: 4
等 级:业余侠客
威 望:3
帖 子:695
专家分:216
注 册:2005-9-25
收藏
得分:0 
顶楼上

长期承接管理系统
代做各种vb/ / vc小程序
QQ:82341763
手机:13623290828
群号 11619730
2011-03-28 09:30
tomjava
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:42
专家分:103
注 册:2011-2-23
收藏
得分:0 
给你调试了一下程序你实现接口中的方法不应该带参数,另外你的继承也出现了问题,还有get()和set(),建议您以后再写代码的时候写上注释,这是一个优秀的程序员的必备!其他不明白的地方可以查询API文档
2011-03-28 12:51
快速回复:谁能帮帮我呀
数据加载中...
 
   



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

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