小明只会写bug 2016-03-04 06:44 采纳率: 0%
浏览 1807

JAVA关于顺序表操作的问题。求大牛

 public class StudScore {

    String name;
    int studentNo;
    double score;

    public StudScore() {

    }

    public StudScore(String name, int studentNo, double score) {
        this.name = name;
        this.studentNo = studentNo;
        this.score = score;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setStudentNo(int studentNo) {
        this.studentNo = studentNo;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public String getName() {
        return name;
    }

    public int getStudentNo() {
        return studentNo;
    }

    public double getScore() {
        return score;
    }

    public String toString() {
        return name + "," + studentNo + "," + score;
    }

}
================================================
public interface StudOPeration {

    void add(StudScore node);

    void listAll();

    void search(int index);

    int getCounts();

    void delete(int index);

    void search(String name);

}
==========================================
public class ArrStudent implements StudOPeration {

    StudScore stud[] = new StudScore[5];
    int count = 0;
    String name;

    public ArrStudent() {

    }

    public ArrStudent(int size) {

    }

    @Override
    public void add(StudScore node) {
        int i = count;
        stud[i] = node;
        count++;

        if (count == stud.length) {
            System.out.println("存储空间已满");
        }
    }

    @Override
    public void listAll() {
        for (int i = 0; i < count; i++) {
            System.out.print(stud[i].name + "\t");
            System.out.print(stud[i].studentNo + "\t");
            System.out.println(stud[i].score);
        }
    }

    @Override
    public void search(int index) {
        if (index <= count && index > 0) {
            System.out.println("您查找信息是:" + stud[index - 1]);
        } else {
            System.out.println("输入的序号无效!!");
        }
    }

    @Override
    public int getCounts() {

        return 0;
    }

    @Override
    public void delete(int index) {

    }

    @Override
    public void search(String name) {



    }

}

现在的问题就是实现了StudOPeration,但是如何获取学生记录个数,根据学生序号删除学生的记录,根据学生的姓名查询学生的记录,根据学生的姓名删除学生的记录。这几个不会做了。求大牛解答。跪谢!!

  • 写回答

3条回答 默认 最新

  • 丑旦 2016-03-04 08:36
    关注

    遍历吧,筛选出stud[]中符合条件,数组的删除费点事。

    评论

报告相同问题?

悬赏问题

  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致