0

我需要一些关于我正在处理的项目的帮助,我需要制作一个钢琴程序,将按下的琴键存储在一个数组列表中,然后当按下播放按钮时,我需要它来播放制作的曲调。我的代码在这里;任何帮助,将不胜感激

import java.util.*;
import student.NoteStore;

/**
 *
 * @author Alex
 */
public class Notestore implements NoteStore {

    ArrayList<Integer> tune = new ArrayList<>();

    @Override
    public void addNote(int note) {
        tune.add(note);
    }

    public void getNextNote(int note) {
        for (int i = 0; i < tune.size(); i++) {
            tune.get(i);
        }
    }

    @Override
    public boolean hasNextNote() {

        if ( == true) {
            return true;
        }
        return false;
    }

    @Override
    public void start(int sortOrder) {
        NoteStore ns = new Notestore();
        ns.addNote(60);
        ns.addNote(62);
        ns.addNote(58);

        //start (with the notes in tune order)
        ns.start(2);
        int note1 = ns.getNextNote();
        int note2 = ns.getNextNote();

        //start again (with the notes in tune order)
        ns.start(2);
        int note3 = ns.getNextNote();

        System.out.println("Notes were " + note1 + "," + note2 + "," + note3);
    }
}
4

0 回答 0