Write some Software
Proyek ini diberikan kepada arcdevsol dengan harga $15 USD.Dapatkan penawaran gratis untuk proyek seperti ini
Anggaran Proyek$10 - $30 USD
Assignment [url removed, login to view]: Programming (Extra Credit)
File [url removed, login to view] (819 B)
In this assignment you will be implementing a linked list and a message queue.
Q1: Create a class called LibraryBook that contains the attributes of a library book, such as author, title, and year, as well as getters and a toString() method. See the UML diagrams below. Create a class called LibraryBookList, which is a linked structure that contains and manages LibraryBook objects. Create a Node class that contains each piece of data and points to the next node. Implement the add(), contains(), get(), remove(), getSize() and isEmpty() methods. The add() method needs to add books to the list and shift the element currently at a specified position in the list and add subsequent elements to the right (add one to their indices), contains() checks to see whether a particular LibraryBook exists in the list and returns true if it is in the list, and returns false if it is not in the list, get() retrieves a particular book in the list based on the index, remove() deletes the element at the specified position of the linked list and shifts the indices behind the removed book, getSize() returns the size of the bookList, and isEmpty() checks to see if the list is empty and if it is it returns true (if it is not empty, return false).
In your LibraryBookList class, using the Java sorting API, keep the books in alphabetical order by title. Refer to the Collections or Arrays classes for useful methods: [url removed, login to view] [url removed, login to view]
Note: You should not use Java's builtin list support (e.g., LinkedList, ArrayList). You must implement the linked data structure yourself from scratch. [25 points]
LibraryBook UML diagram
Q2: Make a driver class called LibraryMain. Create a LibraryBookList and add 4 LibraryBooks to the list, then remove the second and third books from the list. Check if the LibraryBookList is empty. Get the size of the LibraryBookList. Your output should match the output below: [5 points]
Q3: Create a message queue that manages and incoming phone calls and messages in an answering machine. See [url removed, login to view] for a starting place and a description of the methods required in the message queue. Create a Message class that implements Comparable and contains the name of the caller, the date they called, the time, and the length of the call in seconds (as an integer). Make getters and a compareTo method that passes in another Message and compares the length of the messages. This method should compare the length of the two messages and return -1 if the first message is shorter than the second message, 0 if the length of the messages is equal, and 1 if the first message is longer than the second message.
All phone messages are enqueued into the message queue. The highest priority message in a message queue is the message with the shortest length. When dequeueing, your message queue should return the highest priority message, not follow the typical queue FIFO order. Messages should be removed from the queue when the phone call is returned.
In your driver class, create three Message objects and add them to a message queue. Enqueue the messages in an incorrect order (e.g. in ascending order by first name, date, or time). Print out the messages and call the dequeue() method. Note that you may not import any packages. See sample output below: [20 points]
Telusuri Keahlian Terkait
Hal-hal lain yang dilakukan orang di Freelancer
- Products and Features That Maximize Your Freelancer Account
- How to Start a Blog & How to Craft Your First Introductory Post
- How to Launch Your Freelance Company in Just 10 Days
- How to Get Your Name Out There as a Startup: 5 Simple Marketing Strategies
- 9 Sure-Fire Ways to Grow Your Freelance Business
Ingin menghasilkan uang?
- Atur anggaran Anda dan jangka waktunya
- Uraikan proposal Anda
- Dapatkan bayaran atas pekerjaan Anda
Pekerjakan para freelancer yang juga menawar di proyek ini
Bekerja di proyek seperti ini dan menghasilkan uang dari rumah!Daftar Sekarang
- The New York Times
- Wall Street Journal
- Times Online