Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HW4: Methods A File Types java, jpg, and pdf Due Sunday by 9am Points 35 Submitting a file upload Available Jan 8 at 8am -

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

HW4: Methods A File Types java, jpg, and pdf Due Sunday by 9am Points 35 Submitting a file upload Available Jan 8 at 8am - Jan 20 at 11:59pm 13 days Summary 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. Work Items (1) In lab, you should have already installed the Java JDK and the Blue) IDE on your home computer and already used it for OurFirst Program. Recall the Syllabus requirements that it's your responsibility to make sure your program runs in BlueJ.) (2) Draw a flow chart of your second "program." That is to say, create a flow chart of only the contents of the runprogram method (as named below in item 3). You can treat methods called in the runprogram method as black boxes (i.e., you don't have to draw flow charts for those "sub"-methods but just represent them by a single rectangle with the action or method call inside the rectangle - actions may or may not equate to a method call in the code). Submit the image file of a scan of this flow chart: The chart may be handwritten and can be more than one page. Please make it legible. . Your image file can be PDF, JAVA or JPG. . Please submit only one image file via Canvas. Do not email your instructor your work. Name your file Flowchart.jpg (or whatever is the extension for the graphic format you're using). You must name your file this way. (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(); run Program(); } Context Let's consider how we might represent a level from the game Super Mario Bros using just the symbols on a keyboard. Specifically, look at the level design for the first board, and let's see if we can recreate some of the patterns we observe below. We could model the ground with a minus sign, equal sign, or an underscore: Next we could add some "?" boxes to our level (some of the coin and powerup boxes seen between the bricks in the beginning of the level) along with bricks (denoted by the "T" sign): 1?1 11121112111 1112111 To make our task simpler here, we're going to rotate our perspective 90 degrees so that we view the board "top-down" instead of "left-to-right". Just think of this as an exercise in changing your culturally adopted reading style. Some cultures read left-to-right as you are doing now, and some read top-to-bottom; can you think of any languages that are represented differently than this? Either way let's.... R 0 t a t e A General Example of a Mario Board You Will Make 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): A General Example of a Mario Board You Will Make 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): Il // segmenti //segment2 |? II // segment 3 TITITITITIT II Il 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., " // 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 " 1/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. Program A 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 " // segment1 etc. as labels to help you see the modularity of the board segments: Program A 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/segment1 etc. as labels to help you see the modularity of the board segments: Mario Board 1: 11 II // segmenti II II 1/segment2 II 1? II II 1?1 //segment2 repeated II 1/segmenti repeated TI Il //segment3 II 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. Program B 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

More Books

Students also viewed these Databases questions

Question

5-8 What are the advantages and disadvantages of the BYOD movement?

Answered: 1 week ago