Question: Given the following class definition: public class Weapon { private String type; private double speed; } Provide the following: 1) A constructor to initialize

Given the following class definition: public class Weapon { private String type;

Given the following class definition: public class Weapon { private String type; private double speed; } Provide the following: 1) A constructor to initialize the two fields 2) A toString method that returns in the format: "Weapon: Stick, 5.2" 3) Call the two methods that you create above in a main method 4) In the main method, create an Arraylist of Weapon objects and store a weapon object. Print this object using the index. (Not all the elements, just the element at index O)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!