WildcardTester (30) Animal class Create a simple class called Animal instantiated with a name and a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
WildcardTester (30) Animal class Create a simple class called Animal instantiated with a name and a method toString which returns the name. Cat class Create a simple class Cat which extends Animal, but adds no new instance variable or methods. RedCat class Create a simple class RedCat which extends Cat, but adds no new instance variable or methods. Wildcard Tester class Create a class with the main method and methods addCat, delete Cat and printAll as follows. addCat method Has two parameters, an ArrayList with a lower bound of RedCat, and a String with the name of a Cat. Adds the identified Cat reference to the ArrayList, and prints out a line as shown in the sample output below. deleteCat method Has two parameters, an ArrayList with an upper bound of Cat, and a String with the name of a Cat to be deleted. Deletes the identified Cat reference to the ArrayList, and prints out a line as shown in the sample output below. printAll method Has a single parameter of an ArrayList with a wildcard type. Prints out all the items in the ArrayList. main method Create two ArrayLists, one for Animal, and one for RedCat. Use addCat to add "Tiger" to the animal ArrayList. Use addCat to add "Tom", "Siamese" and "Tiger" to the redCats ArrayList. Use printAll to print the list in the animal ArrayList. Use printAll to print the list in the redCat ArrayList. Use deleteCat to delete the first item in the redCat ArrayList. Use printAll to print the list in the redCat ArrayList. Sample Output: Cat Added named Tiger was added Cat Added named Tom was added Cat Added named Siamese was added Cat Added named Tiger was added The list of animals: Tiger The list of redCats: Tom Siamese Tiger Removed cat named Tom The list of redCats after a deletion: Siamese Tiger WildcardTester (30) Animal class Create a simple class called Animal instantiated with a name and a method toString which returns the name. Cat class Create a simple class Cat which extends Animal, but adds no new instance variable or methods. RedCat class Create a simple class RedCat which extends Cat, but adds no new instance variable or methods. Wildcard Tester class Create a class with the main method and methods addCat, delete Cat and printAll as follows. addCat method Has two parameters, an ArrayList with a lower bound of RedCat, and a String with the name of a Cat. Adds the identified Cat reference to the ArrayList, and prints out a line as shown in the sample output below. deleteCat method Has two parameters, an ArrayList with an upper bound of Cat, and a String with the name of a Cat to be deleted. Deletes the identified Cat reference to the ArrayList, and prints out a line as shown in the sample output below. printAll method Has a single parameter of an ArrayList with a wildcard type. Prints out all the items in the ArrayList. main method Create two ArrayLists, one for Animal, and one for RedCat. Use addCat to add "Tiger" to the animal ArrayList. Use addCat to add "Tom", "Siamese" and "Tiger" to the redCats ArrayList. Use printAll to print the list in the animal ArrayList. Use printAll to print the list in the redCat ArrayList. Use deleteCat to delete the first item in the redCat ArrayList. Use printAll to print the list in the redCat ArrayList. Sample Output: Cat Added named Tiger was added Cat Added named Tom was added Cat Added named Siamese was added Cat Added named Tiger was added The list of animals: Tiger The list of redCats: Tom Siamese Tiger Removed cat named Tom The list of redCats after a deletion: Siamese Tiger
Expert Answer:
Answer rating: 100% (QA)
Based on the instructions we need to create a Java program with a few classes demonstrating inheritance and the use of generics with wildcards Lets go ... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Why is an investment portfolio containing a mix of stocks and bonds less risky than one containing a single asset class? Because the markets for stocks and bonds tend to move in the same direction at...
-
Assume that the payoff matrix for a two-person game is given by Then assume that R uses a strategy [r 1 - r]. If C chooses column 1, then R can expect a return of a11r + a21 (1 - r). If C chooses...
-
1. Did I do the right thing even though I lost money in the process? 2. Is it fair of me to judge similar firms more harshly when they submit proposals? 3. Apply the Venn Model to the billing...
-
Reconsider Parts (a) through (f) of Problem 2. For each "true" statement, develop a mathematical proof based on the time value of money factor equations from Table 2.6 in Chapter 2. Data from problem...
-
High Point produces fleece jackets. The company uses JIT costing for its JIT production system. High Point has two inventory accounts: Raw and in-process inventory and Finished goods inventory. On...
-
1 = We know that all the statements [4] Consider the system (0.3)-(0.4) in the particular case f(r) = proven in Problem [3] apply to this case, so for example, we know that c2 7 = - 1 12 (0.6) de and...
-
During orientation, unique group roles emerge. This becomes particularly apparent while working on case presentations. The following interaction occurred during a brainstorming session: Joan: "We are...
-
What is MACRS? In your explanation, please describe the recovery periods, depreciation methods, and depreciation conventions. What is the difference between a recognized gain or loss and a realized...
-
Explain why the following statement is misleading: Apple increases supply of watches following an unexpected increase in demand.
-
Discuss how the development of accounting regulation in Japan has reflected the growth of interaction with international business and trade.
-
Discuss the approaches to corporate governance and audit assurance in China.
-
What are the main features of the corporate reporting system in China?
-
One July, the United States sold aircra worth $1 billion to China and bought aircra worth only $19,000 from China. During the same month, however, the United States bought $83 million worth of mens...
-
As an expert in Strategic Management, suggest four best management practices that can be used by Southeast University to achieve a sustainable competitive advantage. Explain specific actions to be...
-
Consider the discrete group G of order 8 that has the following Cayley diagram e If we have the sequence of operations: fcagec, which of the options represents the reduction of the sequence to a...
-
What would be the effect if the code for the reverse method were changed to the following? public static void reverse (Scanner input) { if (input.hasNextLine () ) { // recursive case (nonempty file)...
-
What is one benefit of making the list iterator into an inner class?
-
Write a method called countQuarters that takes an int representing a number of cents as a parameter and returns the number of quarter coins represented by that many cents. Dont count any whole...
-
You have learned the importance of making sure that requirements are correctly identified. Hut how do you know when you have a correct requirement-that is, what criteria must each requirement meet in...
-
Prepare a full feasibility analysis, including Economic, Operational, Schedule, Legal, and Technical analyses for the system you are suggesting in problem 1. Your analysis should be no more than 30...
-
Complete the following sentences: A critical part of designing the deciding how to distribute the system's data. and to different Databases are a resource typically. by many- future. In designing for...
Islamic Finance In A Nutshell A Guide For Non Specialists 1st Edition - ISBN: 0470748619 - Free Book
Study smarter with the SolutionInn App