谁能帮帮我呀
输出信息.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()没法用,求解!!!!!!!!!小弟感激不尽