zoukankan      html  css  js  c++  java
  • 每日代码系列(17)

     1 interface Achievement {
     2   public abstract float average();
     3 }
     4 class Person {
     5   String name;
     6   int age;
     7   public Person(String newName,int newAge) {
     8     name=newName;
     9     age=newAge;
    10   }
    11   public void introduce() {
    12     System.out.println("你好,我是"+name+",今年"+age+"岁");
    13   }
    14 }
    15 class Student extends Person implements Achievement {
    16   int chinese,math,english;
    17   public Student(String newName,int newAge) {
    18     super(newName,newAge);
    19   }
    20   public void setScore(int c,int m,int e) {
    21     chinese=c;
    22     math=m;
    23     english=e;
    24   }
    25   public float average() {
    26     return (chinese+math+english)/3;
    27   }
    28 }
    29 class C3_2 {
    30   public static void main(String[] args) {
    31     Student s1=new Student("张三",16);
    32     s1.introduce();
    33     s1.setScore(80,90,80);
    34     System.out.println("平均分: "+s1.average());
    35   }
    36 }

    补上周六欠的。

  • 相关阅读:
    Piggy-Bank (hdoj1114)
    Word Amalgamation(hdoj1113)
    Lowest Bit(hdoj1196)
    1206: B.求和
    1207: C.LU的困惑
    STL初步
    关于521(nyoj)
    first blood暴力搜索,剪枝是关键
    变态最大值(nyoj)
    烧饼(nyoj779)
  • 原文地址:https://www.cnblogs.com/ljydbk/p/14128050.html
Copyright © 2011-2022 走看看