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 }

    补上周六欠的。

  • 相关阅读:
    java基础篇6之代理
    JavaWeb 过滤器应用之页面静态化
    JavaWeb 之过滤器
    JavaWeb 之监听器
    分页
    Linux 入门
    多条件组合查询
    Service 事务(JdbcUtils 升级)
    BaseServlet 介绍
    dbUtils 工具类介绍
  • 原文地址:https://www.cnblogs.com/ljydbk/p/14128050.html
Copyright © 2011-2022 走看看