Description
Overview Congrats! You have made it to the shortest PA of the semester. I spent some time trying to think of ways to make this PA harder, but then I realized, why do I need to make it artifically harder? If you learn how to use generics, that is the only goal of this assignment. So please spend some of the time you would normally devote to writing a larger assignment to a careful reviewing and understanding of the links posted on Piazza regarding generics and the lecture content on generics. The purpose of this assignment is to give you practice writing and implementing interfaces, and writing generic classes. The assignment consists of a written part answering questions and a coding part. You can do the written or the coding part first, it is up to you. Assignment Written 1. What is the purpose of generics? Why do we need them? 2. Why don’t we just use Object as the parameterized type for our generic classes? Then we could put absolutely any object into our list. i.e. When we made MyLinkedList generic, why don’t we always declare it like: MyLinkedListllist = new MyLinkedList();13. In class we made MyLinkedList generic and not MyArrayList. Why did we choose to makeMyLinkedList generic first? Are there any issues when combining generics and arrays?4. How many type parameters are you allowed to use in a generic class?5. Explain Type Erasure. How does it work?CodeFor PA7, you will take your implementations of a Stack backed by a linkedList (ListStack.java)and a queue backed by a linkedList (ListQueue.java) and make these implementations generic.This may require adding zero additional lines of code to these files! Wow! You will alsoadapt the StackInterface.java and QueueInterface.java files that we provided in the startercode.First update StackInterface.java. The version we gave you for PA6 has been provided inthe starter code for PA7 as well. This interface is specific to stacks of integers. Make it generic!Update QueueInterface.java. The version we gave you for PA6 has been provided in thestarter code for PA7 as well. This interface is specific to queues of integers. Make it generic!Update your implementation of ListStack to be generic.Update your implementation of ListQueue to be generic.Also, do not forget to override equals, toString, and write a copy constructor just as youdid for the last assignment. You will also need a constructor with zero arguments.A small note: when writing the equals methods for these classes, you might encountera warning like: ”Type safety: Unchecked cast from Object to ListStack”. Do not worryabout it. There is only so much we can cover in this class, we will let this one slide by.Error HandlingWe will use very bad error handling practices in this PA. We have to do this until we learnabout exceptions. If the user calls an erroneous method you should ignore it as best as youcan. Of course, some of the methods still require a return value. Since you have to return anobject of type E. Instead of returning -1 or some other error code. Just return null.Grading CriteriaWe are not providing testcases for this PA. As long as you implement the same methods fromPA6 our autograder will be able to call those methods on your classes. That is how we willtest your implementations. Of course don’t forget to write a copy constructor and override theequals and toString methods. You should not print anything in any of your classes. i.e. do notcall ’System.out.println’ anywhere in your code. You can (and should) use print statementsto debug but be sure to remove them all before submitting your files.We encourage you to write your own JUnit testcases to ensure your classes work properly,but we will not be collecting or grading these test files. We will test your classes with our own2testcases.Your grade will consist of similar style and code clarity points we have looked for in earlierassignments.Write your own code. We will be using a tool that finds overly similar code. Do not look atother students’ code. Do not let other students look at your code or talk in detail about howto solve this programming project. Do not use online resources that have solved the same orsimilar problems. It is okay to look up, ”How do I do X in Java”, where X is indexing into anarray, splitting a string, or something like that. It is not okay to look up, ”How do I solve {aprogramming assignment from CSc210}” and copy someone else’s hard work in coming upwith a working algorithm.3