Question: In Java, write the following program: You are writing a Nethack-style text-based role-playing game that supports saving the game's current state to a text file.
In Java, write the following program:

You are writing a Nethack-style text-based role-playing game that supports saving the game's current state to a text file. You decide to represent items in your character's inventory using certain symbols in the file: + weapon @ potion * dark chocolate bar (Your character is magically prevented from carrying milk chocolate bars.) Write a method that takes a string as a parameter and returns an array containing the quantity of weapons, potions, and dark chocolate bars in that order. You can assume that the input string contains only the three characters above. Required method header: public static int [] countItems (String s) Example input and output: Input: "@@+**+@***" Output: {2, 3, 5}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
