package chapter06; public class Person { //1.数据成员 //1.1私有化数据成员 private String name; private int age; private double datastrure; private double english; //.方法 //2.1空构造方法 public Person() { } //2.2初始化姓名 年龄的构造方法 public Person(String name, int age) { this.name = name; this.age = age; } //2.3 初始化所有数据成员的构造方法; public Person(String name, int age, double ds, double english) { this(name, age); this.datastrure = ds; this.english = english; } //3.setter和getter方法 public void setName(String name) { this.name = name; private double total( ) { this.name = name; } } //4.2计算平均分 private double average() { return this.total() / 2.0; } }
3.20代码任务
最新推荐文章于 2024-11-14 19:49:43 发布