简体   繁体   中英

Doubly Linked List in java implementation

I'm trying to find my to understand and start coding my assignment. We were asked to make a program for score game to set (String name, int score)in descending order. We are restricted to make it as a Doubly Linked List and the node data contain Name and Score, implementation we will do is storing them in descending order, add node, delete node, get node in i position. What I'm thinking of right now, is it a good idea to get the name and score as a HashMap? Am I able to do the implementation in an efficient way?If not HashMap how to store name and score in one node and make the implementations?

how to store name and score in one node...

class Node {
    public final String name;
    public final int score;

    public Node(String name, int score) {
        this.name = name;
        this.score = score;
    }
}

Of course, you might want to add some other fields and probably some methods if you want to link your Node objects to one another in a doubly linked list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM