Question: This assignment deals with string manipulation problems. ? Use only the charAt, equals, length, substring, and toUpperCase methods of the String class (see the Java

This assignment deals with string manipulation problems.

? Use only the charAt, equals, length, substring, and toUpperCase methods of the String class (see the Java API for details) in your solutions. ? The methods youre writing for this assignment simply make use of String objects. Youre not actually writing new methods for Javas built-in String class! Thus, all your methods can be declared as static, just like most of the ones you wrote in COMP 1900.

? The 1980 computer game Rogue is a dungeon crawler that features procedurally generated levels and simple text-based graphics as shown below. Procedurally generated means that the levels are automatically produced by an algorithm and are different each time the game is played, as opposed to having levels manually designed by a human. Rogue inspired an entire genre of similar games called Roguelikes that have an active player base even today.

This assignment deals with string manipulation problems. ? Use only the charAt, As you can see from the screenshot, a Rogue level uses different text characters to represent various features:

| vertical wall - horizontal wall . room space # corridor + doorway

You want to write some code to help you analyze Rogue levels. Because the levels contain only text characters, this is a great chance to practice working with strings!

A. ? Write a method countDoors(String s). This method takes a line from a Rogue level as a parameter, and it returns the number of doorways in that line.

Example:

countDoors("----+---- # ---+-----") should return 2.

B. ? Write a method countFeatures(String s). This is similar to the countDoors method, but it returns an array containing the number of vertical walls, horizontal walls, room spaces, corridors, and doorways (in that order).

Example:

countFeatures("----+---- # ---+-----") should return the array {0, 16, 0, 1, 2}.

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 Databases Questions!