Question

List of Candles Create a class called CandleNode which has fields for the data (a Candle)...

List of Candles
Create a class called CandleNode which has fields for the data (a Candle) and next (CandleNode) instance variables. Include a one-argument constructor which takes a Candle as a parameter. (For hints, see the PowerPoint on "Static vs. Dynamic Structures”.)
public CandleNode (Candle c) { . . }
The instance variables should have protected access. There will not be any get and set methods for the two instance variables.

Create an abstract linked list class called CandleList. This should be a linked list with head node as described in lecture. Modify it so that the data type in the nodes is Candle. The no-argument constructor should create an empty list with first and last pointing to an empty head node, and length equal to zero. Include an append method in this class.

Create two more linked list classes that extend the abstract class CandleList: One called UnsortedCandleList and one called SortedCandleList, each with appropriate no-argument constructors. Each of these classes should have a method called add(Candle) that will add a new node to the list. In the case of the UnsortedCandleList it will add it to the end of the list by calling the append method in the super class. In the case of the SortedCandleList it will insert the node in the proper position to keep the list sorted.

Instantiate two linked lists, and for every Candle read from the file, add it to the unsorted and sorted lists using the add method. You will end up with the first list having the Candles from the input file in the order they were read, and in the second list the Candles will be in sorted order. Display the unsorted and sorted Candles in the GUI just as in project 1.


Submitting the Project. You should now have the following files to submit for this project:
Project2.java

Candle.java

CandleGUI.java

CandleNode.java

CandleList.java

UnsortedCandleList.java

SortedCandleList.java

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
List of Candles Create a class called CandleNode which has fields for the data (a Candle)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a class called CarNode which has fields for the data (a Car) and next (CarNode)...

    Create a class called CarNode which has fields for the data (a Car) and next (CarNode) instance variables. Include a one-argument constructor which takes a Car as a parameter. (For hints, see the PowerPoint on "Static vs. Dynamic Structures”.) public CarNode (Car c) { . . } The instance variables should have protected access. There will not be any get and set methods for the two instance variables. Create an abstract linked list class called CarList. This should be a...

  • Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one me...

    Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one menu item called Search. Clicking on search should prompt the user using a JOptionPane input dialog to enter a car make. The GUI should then display only cars of that make. You will need to write a second menu...

  • Implement the following classes in the UML: 1. List class includes:       constructor List(): Create an...

    Implement the following classes in the UML: 1. List class includes:       constructor List(): Create an empty list with a length of 100. Hint: double [] list = new double [100];       constructor List(len: int): Create a List with a user specified maximum length. Hint: double [] list = new double [len];       add: add a new element to the end of the unsorted list.       print: display the list 2.SortedList class includes       two constructors : similar to the...

  • Need help to create general class Classes Data Element - Ticket Create an abstract class called...

    Need help to create general class Classes Data Element - Ticket Create an abstract class called Ticket with: two abstract methods called calculateTicketPrice which returns a double and getld0 which returns an int instance variables (one of them is an object of the enumerated type Format) which are common to all the subclasses of Ticket toString method, getters and setters and at least 2 constructors, one of the constructors must be the default (no-arg) constructor. . Data Element - subclasses...

  • c++ modify the attached unsorted linked list class into a sorted linked list class #include <iostream>...

    c++ modify the attached unsorted linked list class into a sorted linked list class #include <iostream> using namespace std; template<class T> struct Node {     T data;//data field     Node * next;//link field     Node(T data) {       this->data = data;     } }; template<class T> class linked_list{ private:       Node<T> *head,*current; public:       linked_list(){//constructor, empty linked list         head = NULL;         current = NULL;       }       ~linked_list(){         current = head;         while(current != NULL) {          ...

  • In C++ - Learn how to implement linked lists Part 1 Node and Linked List Class...

    In C++ - Learn how to implement linked lists Part 1 Node and Linked List Class (50 pts): Create node with public properties: Block type block and block ptr next. Create a linked list class that uses the node you generated without an add or delete method with a head and optional tail and counter. Make a driver that generates a node to test your implementation. Part 2 Add Method (30 pts): Create an add method in your linked list...

  • Static methods can be called directly from the name of the class that contains the method....

    Static methods can be called directly from the name of the class that contains the method. Static methods are usually created to do utility operations. For example: public class Test{ public static int timesTwo(int value){ return value * value; } } public class TestDriver{ public static void main(String[] args){ int var = Test.timesTwo(5);   System.out.println(var); } } For your final exercise, create a class called ManyLinkedLists. It will contain a static method called createLinkedList(). That method takes an argument that is...

  • Static methods can be called directly from the name of the class that contains the method. Static methods are usually created to do utility operations. For example: public class Test{ public static i...

    Static methods can be called directly from the name of the class that contains the method. Static methods are usually created to do utility operations. For example: public class Test{ public static int timesTwo(int value){ return value * value; } } public class TestDriver{ public static void main(String[] args){ int var = Test.timesTwo(5);   System.out.println(var); } } For your final exercise, create a class called ManyLinkedLists. It will contain a static method called createLinkedList(). That method takes an argument that is...

  • Write a program that meets the following requirements: Sandwich Class Create a class called Sandwich which has the following instance variables. No other instance variables should be used: - ingredi...

    Write a program that meets the following requirements: Sandwich Class Create a class called Sandwich which has the following instance variables. No other instance variables should be used: - ingredients (an array of up to 10 ingredients, such as ham, capicola, American cheese, lettuce, tomato) -condiments (an array of up to 5 condiments, such as mayonnaise, oil, vinegar and mustard) Create a two argument constructor Write the getters and setters for the instance variables Override the toString method using the...

  • 1. Create a class MLL, a singly linked, non-circular list where each node only has one...

    1. Create a class MLL, a singly linked, non-circular list where each node only has one link next and the list has a head and a tail link (think about implementation of node). The MLL class also implements the Iterable interface. The following should be implemented as well: 2. Add the methods to the MLL class: a. iterator() to implement the Iterable interface. This method returns an instance of MLLI initialized appropriately. b. addFirst( value) that adds a value to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT