Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this lab assignment, we will create a sorted doubly-linked list class, and use that class to implement the outline of a speed-priority battle system.
In this lab assignment, we will create a sorted doubly-linked list class, and use that class to implement the outline of a speed-priority battle system. Instructions Our battle game needs to support warriors of different speeds properly. A priority queue seems like an appropriate data structure for the task, but you haven't covered that yet in your computer science courses. Let's try to implement a basic doubly linked list that implements a priority system by sorting the elements that are inserted. The driver code that follows can be used to test your linked list: public class LinkedListoriver public static void main(Stringl 1 args) t Linkedlist list-new SortedDoublyLinkedLst(); System.out.printIn(1ist) Warrior krogg new Warrior("Krogg" 30 50, 200)i list.insert(krogg) System.out printin (list) Warrior gurkh new warrior ("Gurkh", 40, 45, list insert( gurkh)i 180); System.out printin(list) warrior brynn-new warrior("Brynn", list.insert(brynn) 45, 40, 190); System.out-printin(list); warrior dolf #new Warrior ("Dolf", list.insert (dolf)i 20, 65, 210), System.out.printin(list) Warrior zuni new Warrior (Zuni", 50, 35, 170) list.insert (zuni)a System.out.printin(list); The Warrior class has also been included. to make your job easier: public class warrior t private String name; private int speed; private int strength private int hp: public waTO(String hame, int speed, Ent str, int hp) this name name this.spped speed this strengthstri this.hp+ hp; public String getName ()return this.name ; public int getspeed return this speed:h public in getstrength() { return this. strength; In this lab assignment, we will create a sorted doubly-linked list class, and use that class to implement the outline of a speed-priority battle system. Instructions Our battle game needs to support warriors of different speeds properly. A priority queue seems like an appropriate data structure for the task, but you haven't covered that yet in your computer science courses. Let's try to implement a basic doubly linked list that implements a priority system by sorting the elements that are inserted. The driver code that follows can be used to test your linked list: public class LinkedListoriver public static void main(Stringl 1 args) t Linkedlist list-new SortedDoublyLinkedLst(); System.out.printIn(1ist) Warrior krogg new Warrior("Krogg" 30 50, 200)i list.insert(krogg) System.out printin (list) Warrior gurkh new warrior ("Gurkh", 40, 45, list insert( gurkh)i 180); System.out printin(list) warrior brynn-new warrior("Brynn", list.insert(brynn) 45, 40, 190); System.out-printin(list); warrior dolf #new Warrior ("Dolf", list.insert (dolf)i 20, 65, 210), System.out.printin(list) Warrior zuni new Warrior (Zuni", 50, 35, 170) list.insert (zuni)a System.out.printin(list); The Warrior class has also been included. to make your job easier: public class warrior t private String name; private int speed; private int strength private int hp: public waTO(String hame, int speed, Ent str, int hp) this name name this.spped speed this strengthstri this.hp+ hp; public String getName ()return this.name ; public int getspeed return this speed:h public in getstrength() { return this. strength
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started