Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this assignment is to construct two separate Java programs that produce three distinct levels or boards similar to those found in the

The purpose of this assignment is to construct two separate Java "programs" that produce three distinct levels or boards similar to those found in the Super Mario Brothers brand of games. These Java "programs" will rely on method calls to reduce redundancy in your software. Additionally, you will get to practice the website tools and submission procedure to use for future homework.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

(3) Write the two "programs," Program A and B, described below. Submit the single Java file (i.e., ".java text file) that contains your two "programs." The "programs will actually simply be two methods: Please submit only a single Java file via Canvas (below I describe how you put two "programs" into one file). Do not email your instructor your work. Name your Java file HW_Methods.java. You must name your file this way. Note that by requiring you name your Java file HW_Methods.java, it means that the public class that is in that file has to be named Hw_Methods . Each of your programs should be called by a method. Those methods should be written in the same class as your program. Your Java file must have a main method that calls these two methods. Thus, your main method should look exactly like this: public static void main(String[] args) { runPrograma(); runProgramB(); } Your task is to write a program that outputs two distinct levels or boards from a Mario game. Your level will be constructed from multiple smaller segments that you will "string together" by code you will write that will define different methods that will implement the defined Mario Boards by calling the correct functions from your main (programA and programB see explanations below) and within those two methods, invoking other methods in a sequence that will create the boards that are required. Here is an example Mario level (note that some parts of the board are duplicates - use methods for all segments to avoid duplicate code): II 11 // segmenti |?| // segment2 |?| TIITTI //segment3 11 Note that by changing our perspective, the l" character now represents the "ground" while the hyphen represents vertical towers or other vertical structures (that are not the ground). The text that kind of hovers in the air, e.g., 1/segment2", are comment lines that indicate the portion to the left can be thought of as a unit or chunk of the board. The syntax of that text follows the Java syntax for comments. Your program should not write out // segment2 " etc.; they are just there to tell you to consider that group of lines as a segment. Also, we show a blank line between segments to help make the segments stand out (the same is true for the other example boards below). You shouldn't write out those blank lines (i.e., your board should be continuous). For this assignment go ahead and use the three segments shown above. The first "program" will clone the output from the above example and will use it to create two different Mario boards. Call the first "Mario Board 1" and the second "Mario Board 2". These two boards will be the same text for the individual segments, but each will have unique look due to the order and number of method calls in your programA method that is invoked in main(). For example, you could redesign the level above as a longer level while reusing the same basic building blocks; here would be that output (which I preface by the label Mario Board 1"), again with the " 1/ segmenti " etc. as labels to help you see the modularity of the board segments: Mario Board 1: IL 11 11 11 // segmenti |?| ====== 1/segment2 1?! 1?1 // segment2 repeated 1?1 // segmenti repeated 11 // segment 3 Il Again, I am only showing you an example of Mario Board 1. Your Program A has to write out both "Mario Board 1" and "Mario Board 2." That is, both boards are written out when executing runprograma. Design your own "Mario Board 1" and "Mario Board 2" levels by using 5 or 6 combinations of these three pre-defined segments for each one. This "program" is quite similar to the first, so you might consider making a copy of your first program as a starting point for your second. In future weeks, we'll discuss better techniques for code reuse than simply copying and pasting, but for this assignment, this is a fine way to shorten the work you have to do. The goal of the second program is to ask the user for the unique text representation of the hero Mario and of a coin; then your program will build a board and place Mario somewhere in it, as well as one or more coins. To do the user input from the console (keyboard), you will want to use the Scanner class. A sample execution of this program might look like: What does Mario Look like? >--

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

=+What would you say if the person were in front of you?

Answered: 1 week ago