Resource CST-135 Activity 3 Guide Contents Part 1: Refactoring Weapons Classes to Use Interface Design2 Part 2 Java Generics4 Part 3 Collections (List, HashMap, Queue and Stack)7 This activity has...

1 answer below »
Complete Activity 3


Resource CST-135 Activity 3 Guide Contents Part 1: Refactoring Weapons Classes to Use Interface Design2 Part 2 Java Generics4 Part 3 Collections (List, HashMap, Queue and Stack)7 This activity has multiple parts. All parts must be completed prior to documentation submission. Your instructor will provide the materials necessary to demonstrate and explain the steps in each of these activities. Part 1: Refactoring Weapons Classes to Use Interface Design Goal In this activity, you will learn how to refactor the code from the weapons classes done in a previous activity to use Interface classes and demonstrate polymorphism. You will build a simple class hierarchy of game weapons using abstract classes. Execution Execute this assignment according to the following guidelines. 1. Refactor Base Weapon class: a. Remove the Weapon abstract class and create a new Interface class named WeaponInterface. b. Add a public method fireWeapon() that returns void and takes no arguments. c. Add a public method fireWeapon() that returns void and takes a power argument as an integer type. d. Add a public method activate() that returns void and takes an argument as an boolean type. 2. Refactor the specialization Weapon Classes: a. Refactor the Bomb class so that it implements the WeaponInterface class. b. Refactor the Gun class so that that it implements the WeaponInterface class. 3. Refactor the Game Class: a. Remove all existing game logic in main(). b. Create a private helper method fireWeapon() that takes a WeaponInterface as an argument as a weapon. For the passed in weapon activate the weapon then fire the weapon. c. Create an array of type WeaponInterface that can hold two weapons. d. Initialize the first array element with a Bomb. e. Initialize the second array element with a Gun. f. Loop over the weapons array and call fireWeapon() for each weapon. g. Take a screen shot of the final output. 4. Write up: a. Draw a UML Class Diagram of your solution. b. In three to four sentences, describe where and how polymorphism was demonstrated in your code. c. Generate the JavaDoc for all classes. Deliverables This activity has multiple parts. All parts must be completed prior to documentation submission. See the instructions at the end of this activity. For this part of the activity you will need to include: 1. ZIP file containing the source code of the application, including the generated JavaDoc files. 2. Word document containing captioned screen shots that show the application being run successfully. Part 2 Java Generics Goal Write Java classes that use Java generic classes, methods, and bounded generics. Execution Execute this assignment according to the following guidelines: 1. Create a new project. 2. Generic Class Type: a. Create a new class named Storage class with main(). b. Define the Storage class with a Generic Class type T. c. Create a private class member variable named s of type T. d. Create a nondefault constructor that takes a single method argument of type T. Save the method argument in the private class member variable. e. Create a public method named getData() that returns private class member variable (of type T). f. In main(), create an instance of Storage class to support a String and print its return value to the console by calling its getData() method. g. In main(), create an instance of Storage class to support an integer and print its return value to the console by calling its getData() method. h. Run the application. i. Take a screen shot of the console from Step 2h. 3. Generic Method Type and Bounded Generic: a. Create a new class named MyArray class with main(). b. Create a public method named printArray() that takes a single method argument of a generic array (of type E). In its implementation, loop over the array and print each value of the array to the console. c. In main() create three arrays of type Integer, Double, and Character. d. In main(), create an instance of MyArray class and print each array by calling its printArray() method. e. Run the application. f. Take a screen shot of the console from Step 3e. g. Copy the MyArray class to a new class named MyNumberArray. h. Update the printArray() method to restrict the Method Generic Type to a Number type. i. Fix the array types declared in main() to resolve any compiler errors. j. Run the application. k. Take a screen shot of the console from Step 3j. 4. More Generic Method Type and Bounded Generic: a. Create a new class named Calculator with main(). b. Create a public method named add() that takes two method arguments of a generic type T that is bounded to the BigDecimal or Number type. In its implementation, add the two numbers and return the value. c. Create a public method named subtract() that takes two method arguments of a generic type T that is bounded to the BigDecimal or Number type. In its implementation, subtract the two numbers and return the value. d. In main() create an instance of the Calculator class. i. Add two integers and print the result to the console. ii. Add two floating point numbers and print the result to the console. iii. Subtract two integers and print the result to the console. iv. Subtract two floating point numbers and print the result to the console. e. Run the application. f. Take a screen shot of the console from Step 4e. Deliverables This activity has multiple parts. All parts must be completed prior to documentation submission. See the instructions at the end of this activity. For this part of the activity you will need to include: 1. ZIP file containing the source code of the application. 2. Word document containing captioned screen shots that show the application being run successfully. Part 3 Collections (List, HashMap, Queue and Stack) Goal Write Java classes that use Java Generic Classes, Methods, and Bounded Generics. Execution Execute this assignment according to the following guidelines. 1. Create a new project. 2. ArrayList: a. Create a new class named PlayList class with main(). b. Create an ArrayList of Integers. Add five numbers to the List. c. Create an ArrayList of Strings. Add five strings to the List. d. Print the first element of each ArrayList to the console. e. Print the Integer List using a for loop to the console. f. Print the String List using a while loop to the console. g. Run the application. h. Take a screen shot of the console from Step 2g. 3. HashMap: a. Create a new class named PlayMap class with main(). b. Create an HashMap of Integers. Add five numbers to the Map. c. Create an HashMap of Strings. Add five strings to the Map. d. Print the size and if empty for each HashMap to the console. e. Print the String Map using a for loop to the console. f. Remove all elements for each of the Maps. g. Run the application. h. Take a screen shot of the console from Step 3g. 4. Queue: a. Create a new class named PlayQueue class with main(). b. Create a Queue of Integers. Add five numbers to the Queue. c. Create a Queue of Strings. Add five strings to the Queue. d. Print the size and if head element for each Queue to the console. e. Print the Integer Queue using toString() to the console. f. Print the String Map using a while loop to the console. g. Run the application. h. Take a screen shot of the console from Step 4g. 5. Stack: a. Create a new class named PlayStack class with main(). b. Create a Stack of Integers. Push five numbers to the Stack. c. Create a Stack of Strings. Push five strings to the Stack. d. Print the size and if 2nd element for each Stack to the console. e. Print the Integer Stack using toString() to the console. f. Print the String Stack using a while loop to the console. g. Run the application. h. Take a screen shot of the console from Step 5g. 6. Tutorials: a. Go the "Java Collections Tutorial" provided in Topic Materials. b. Review all the tutorials. c. Complete Collection Quiz-1. Take a screenshot of your completed quiz. Deliverables This activity has multiple parts. All parts must be completed prior to documentation submission. A good way to organize the assignment is to create separate folders for each section and ZIP the entire project. Inside each of these folders is usually another ZIP file that contains the project code and a Word document that contains screen shots of the application being demonstrated. © 2020. Grand Canyon University. All Rights Reserved. © 2021. Grand Canyon University. All Rights Reserved.
Answered Same DayMay 19, 2021

Answer To: Resource CST-135 Activity 3 Guide Contents Part 1: Refactoring Weapons Classes to Use Interface...

Vaishnavi R answered on May 20 2021
140 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here