21 Aug Create 3 queues, one called Animal Shelter, another called Cats, and another called Dogs.
Final Challenge #6: Adopt-a-Pet
- Due Nov 24 by 11:59pm
Use the LinkedList class to simulate a queue, and use the add method to simulate the enqueue, and the remove method to simulate the dequeue method for a Queue. Remember to use FIFO.
Create 3 queues, one called Animal Shelter, another called Cats, and another called Dogs. Use the following menu-driven application:
1. Adopt a Cat
2. Adopt a Dog
3. Adopt Oldest Pet
4. Donate a Cat
5. Donate a Dog
6. Add New Microchips
7. Exit
Create a Pet class that will be instantiated with the values in the following attributes: String name, int dateOfBirth //yyyymmdd format, String species, Long microchipNumber.
Note: The Dog queue and Cat queue are “regular” queues, and the Animal Shelter queue is a Priority Queue, where the priority is based upon the dateOfBirth of the pet. The older the pet, the higher its priority. See the attached .zip file for examples of a PriorityQueue.
Each week, on Monday before the Animal Shelter opens, an administrator of the Animal Shelter adds more microchips to the stack of microchips, so that there will be enough microchips to put in any animal that is donated into the shelter that week. To simulate this, you will create a menu option, which will generate 100 microchip long objects, and place them into a stack of microchips. Those microchip objects will be generated by using the System.nanotime() method.
Each time a person donates a cat or dog, ask for the name of the pet, the species, and the date of birth, and pop the microchip stack to get a chip to put in the pet. Create a new Pet object. Then, add the Pet object to both its specific species queue, and the general Animal Shelter queue. If the stack of microchips is empty, give an error message to the user, stating the pet cannot be donated because there are no microchips left. Ask the user to press option 6 to get more microchips.
When a person selects to adopt a specific species pet, remove the first pet object from the appropriate species queue, and also from the Animal Shelter queue. Take care to find the pet in the Animal Shelter queue, and remove it, but put back all the others that follow it, in the same order you found them (hint: You may need to create a new queue, removing the dog or cat that needs to be dequeued, and keeping all the rest. Once the new queue is created, point the old queue to the new queue.)
When a person comes in to adopt the oldest pet in the shelter, then process the Animal Shelter as a PriorityQueue, where the pet’s date of birth is the attribute used to retrieve the oldest pet (hint: Pet class should implement Comparable, and should define a compareTo method that would sort in ascending date-of-birth order. ) So, when you dequeue the Animal Shelter as a Priority Queue, you will automatically get the Pet with the earliest/oldest date of birth first . Then, after removing the oldest pet object from the animal shelter, then dequeue it from the appropriate species queue (will have to do a sequential search in the the appropriate queue, according to the Pet object’s species attribute. See hint above for keeping the exact order in the queue).
Create 4 global variables that represent the 3 queues for dogs, cats, and animal shelter (Priority Queue based on date-of-birth of pet), and the stack for the microchips. Create methods that can be called multiple times to accomplish all of the menu options. The names of the methods should be:
donateCat(), donateDog(), adoptCat(), adoptDog(), donateAnimal(), adoptAnimal(), pushMicroChip(), popMicroChip()
Note: Attached zip file Download Attached zip file gives examples of using a LinkedList as a Queue, and as a PriorityQueue. The attached file is NOT meant to be a skeleton.
THE ZIP FILE HAS TO BE UPLOADED TO THE COMMENTS SECTION!!
____________________________________________________
Per the syllabus Requirements:
Assignments:
Each week, students will be assigned a CHALLENGE program, which will be started during the lab time, and must be completed and turned in via Canvas by midnight on Sunday. All programming assignments are required to be turned in as “zipped” Netbeans projects, so that the graders can have a consistent means of “unzipping” and testing the programs.
Ensure your student id, section, and due date appear in the comments of your programming assignments, to give you proper credit. Do not put your name in the comments, since we use anonymous grading.
Naming Conventions for Files:
In Netbeans, name your project file as follows:
Challenge#_PID (Mine is: Challenge_5C_6312209)
Check that the zipped assignment you turned in to Canvas is the correct assignment. Download the zipped file from Canvas and double-click it until you get to the source folder. Then double click the .java files within the source folder and visually inspect the .java file using Notepad or Wordpad, to ensure it is the correct assignment.
If you mistakenly upload the wrong program, and it is BEFORE the deadline, and it has NOT been graded yet, you can re-upload the correct version. If the program has already been graded, you are not allowed to re-upload it for a better grade. Your original grade will stand, even if it is a 0 for submitting the wrong assignment, and your re-submission will not be graded.
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Wridemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Place Order” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.