为了账号安全,请及时绑定邮箱和手机立即绑定

学生管理系统控制台模拟

标签:
Java

// 学生管理类
public class StudentMange {
// 创建arraylist存储学生对象
public ArrayList<Student> students = null;

// 初始化数据
public ArrayList<Student> init(){
    Student student1 = new ComputerStudent("1001", "evan", 21, 99, 98);
    Student student2 = new ArtStudent("1002", "daisy", 62, 59, "素描");
    students.add(student1);
    students.add(student2);
    return students;
}

public void saveComputer(Student student){
    students.add(student);
}

public ArrayList<Student> list(){
    return students;
}

}

// 艺术生类
public class ArtStudent extends Student{
// 子类的属性
protected String Specialty;

//重写父类的方法
public void action(){
    System.out.println("喜欢画画");
}

public void create(){
    System.out.println("制造作品");
}

public String getSpecialty() {
    return Specialty;
}

public void setSpecialty(String specialty) {
    Specialty = specialty;
}

// 构造函数
public ArtStudent(){

}

public ArtStudent(String id, String name, int age, float score,String Specialty){
    this.id = id;
    this.name = name;
    this.age = age;
    this.score = score;
    this.Specialty = Specialty;
}

}

// 计算机系学生

public class ComputerStudent extends Student{
// 子类的属性
protected float projectScore;

// 重写父类的方法
public void action(){
    System.out.println("喜欢玩电脑");
}

public void programming(){
    System.out.println("编程行为");
}

public float getProjectScore() {
    return projectScore;
}

public void setProjectScore(float projectScore) {
    this.projectScore = projectScore;
}

// 构造函数
public ComputerStudent(String id, String name, int age, float score, float projectScore) {
    this.id = id;
    this.name = name;
    this.age = age;
    this.score = score;
    this.projectScore = projectScore;
}

public ComputerStudent(){

}

}

// 学生类
package com.evan.model;

public class Student {
// 属性
protected String id;
protected String name;
protected int age;
protected float score;

// 行为
public void action(){

}

// 构造函数
public Student(){

}

public Student(String id, String name, int age, float score) {
    this.id = id;
    this.name = name;
    this.age = age;
    this.score = score;
}

public String getId() {
    return id;
}
public void setId(String id) {
    this.id = id;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public int getAge() {
    return age;
}
public void setAge(int age) {
    this.age = age;
}
public float getScore() {
    return score;
}
public void setScore(float score) {
    this.score = score;
}

public String toString() {
    return "id:"+id+",name:"+name+",age:"+age+",score:"+score;
}

}

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消