Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*****Please use this initial code to complete**** java code MUST PASS ALL THE REQUIREMENT AND PLEASE USE INITIAL CODES // Skyscraper.java import java.io.FileNotFoundException; /** *

*****Please use this initial code to complete**** java code

MUST PASS ALL THE REQUIREMENT AND PLEASE USE INITIAL CODES

// Skyscraper.java

import java.io.FileNotFoundException; /** * Reads in configurations of potential solutions to Skyscraper puzzles and * evaluates their validity before printing out both the grids and their status * as an answer to the puzzles. */ public class Skyscraper { /** * The driver method to process Skyscraper puzzle settings * The task is to check their validity and then print the grids along with the results of those checks. * * @param theArgs is used for command line input. */ public static void main(final String[] theArgs) throws FileNotFoundException { if (theArgs.length != 1) { System.out.println("ERROR: Program must be run using the name of an input file that " + "contains skyscraper information as a command line argument."); } else { // START FILLING YOUR CODE HERE // END FILLING YOUR CODE HERE System.out.println("COMPLETED PROCESSING SKYSCRAPERS"); } } /** * Prints the Skyscraper puzzle configuration and whether it is valid or not as * a solution. * * @param theGrid is a 2D integer array representing a configuration of * integers as a potential answer to a Skyscraper puzzle. * @param theValidity is a boolean value representing whether the 2D integer * array is an acceptable solution or not. */ public static void printSkyscrapers(final int[][] theGrid, final boolean theValidity) { final StringBuilder sb = new StringBuilder(); for (int row = 0; row  

// skyscraper_1.txt (small input file)

3 2 2 1

3 13 2 4 1

2 2 1 4 3 2

1 4 2 3 1 3

2 3 4 1 2 2

2 1 3 3

1 2 3 4

3 1 3 2 4 1

2 2 1 4 3 2

1 4 2 3 1 3

2 3 4 1 2 2

2 1 3 3

// skyscraper_2.txt (big input file)

3 2 4 1

3 2 3 1 4 1

2 34 2 1 3

1 4 1 3 2 3

3 1 2 4 3 2

2 2 1 2

2 1 4 2

2 2 4 1 3 2

3 1 3 2 4 1

1 4 1 3 2 3

2 3 2 4 1 2

2 3 1 3

3 2 2 1

3 1 3 2 4 1

2 2 1 4 3 2

1 4 2 3 1 3

2 3 4 1 2 2

2 1 3 3

2 2 4 1

2 3 2 1 4 1

1 4 1 2 3 2

2 1 4 3 2 3

3 2 3 4 1 2

2 1 3 3

2 2 4 1

2 3 1 2 4 1

2 2 4 3 1 3

3 1 3 4 2 2

4 2 1 2

1 2 3 4

3 1 3 2 4 1

2 2 1 4 3 2

1 4 2 3 1 3

2 3 4 1 2 2

2 1 3 3

2 2 4 1

3 4 2 3 2 1

2 3 3 3 3 2

1 1 1 3 3 3

2 3 2 2 3 2

2 2 1 4

2 1 2 3

2 3 4 2 1 3

3 1 2 4 3 2

1 4 1 3 2 3

2 3 1 3 4 1

2 3 2 1

3 1 2 3

2 2 2 2 3 3

2 2 1 3 2 2

1 3 4 4 2 2

3 1 2 3

4 1 2 2

3 1 1 3 2 3

1 1 2 3 4 3

2 3 2 4 1 2

3 3 3 4 2 1

2 1 2 4 3 2

2 1 3 2

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

PLEASE MAKE SURE TO FOLLOW THE RUBRIC....

e program does not compile will receive grade of zero. ce your code in a class named Skyscraper and the class. - The class should contain a main method which should do the following for the Skyscraper class: 1. Check for the name of the input file specified as a command line argument. If the file is not there print an error message telling the program user the program must be run using the name of an input file that contains skyscraper information as a command line argument. 2. Open the file 3. Read from the file as long as there is skyscraper information - for each set of skyscraper data do the following: a. Using the method getSkyscrapers to assign the clues and skyscraper heights into at least one two-dimensional array of type int (if you would like to have one array for the clues and another for the skyscraper heights that is fine). The size of the 2D array should be 66. That means the top right, top left, bottom right, and bottom left corners should have unused values which are all zeroes b. Pass the 2D array just read to a method called validateskyscrapers. The method should examine the clues and the skyscraper heights and return true if the heights are valid based on the clues, false otherwise. c. Print the skyscraper clues and heights in the format specified above along with a message about whether the heights are valid (as specified above). The code to do this should be placed in a method printSkyscrapers which is passed whatever data you feel is necessary to print the required information. Note: the method printSkyscrapers is optional to implement. 4. Close the input file. 5. Print a message that says "COMPLETED PROCESSING SKYSCRAPER S" (without the quotes) 6. You are welcome to write helper methods to complete the tasks above - modular design is an important part of good software development - Be sure your code follows the naming and coding conventions for the class: 1. Instance fields of a class should be named starting with 'my' 2. Parameters to methods should be named starting with 'the' 3. Parameters to methods should be specified as final 4. Javadoc comments should be used for the class as well as the methods of the class 5. You will lose points for each of these things on every assignment if you do not adhere to the rules. 6. See this document for specifics (as well as an example): https://www.oracle.com/java/technologies/javase/codeconventions-introduction.html Submit to Canvas a zip file named assignment01_LA STNAME_FIRSTNAME.zip (all lower cases) that contains the following files: (assignment01_hoang_varik.zip for example) - Skyscraper.java documented and styled according to class standards. - A readme.txt file that contains the following information 1. Your name 2. An estimate of the amount of time you spent completing the assignment 3. Any problems that exist in the project (if there are not any please state so) 4. Any questions you have for Varik about the assignment Rubric: Note: must pass all criterias if using LGS Assignment \#1 - Skyscrapers Background: The purpose of this assignment is to review lectures in 2D-array, nested for loops, file input (scanner). This assignment will give you practice working with single and multidimensional arrays as well as basic data structures. The students will also be able to develop and implement program involving the fundamental programming constructs such as variables, types, expressions, assignment, simple I/O, conditional and iterative control structures, functions and parameter passing, structured decomposition. Objectives: This assignment will assess your mastery of the following objectives: - Write a functionally correct program to produce specified console output. - Use nested for-loop to check the content in the 2D array. - Operate the file I/O (input/output) to read data from and write to file using Scanner class. - Follow prescribed conventions for spacing, indentation, naming methods, and header comments. Skyscraper is a puzzle where integer values from 1 through 4 are used to represent the height of skyscrapers on a 4 by 4 city grid, where a building of height 1 is the shortest. The outside of the 4 by 4 gric contain clue values. These values also range from 1 through 4 and represent the number of buildings that can be seen from a given row or column in the city grid. Each row and column of the city grid must not contain two buildings that are the same height for a solution to be valid. More specifically, each row and column must contain buildings with heights 1 through 4 . The rules for the values in the skyscraper grid are a little like those of Sudoku, for those that have played that. The image shows below on the left is an empty city grid with clues to the left with a completed city grid to the right that satisfies the clues given on the left. Your task is to write a program that reads from an input file whose name is specified as a command line argument. The file will contain data on one or more complete skyscrapers (including clues). For each skyscraper, you must determine if the skyscraper properly satisfies the clues. You do not have to worry about how to solve the puzzle. The solution of the puzzle is also provided in the green cells. The data in the file is guaranteed to be well-formed, so no error checking is required. The first line of data for a skyscraper will be the top clues for the 4 columns. The second line will start with the clue for the row looking from left to right, followed by the 4 skyscraper heights, followed by the clue for that row looking fror right to left. Lines 3,4 , and 5 will be formatted as line 2 . The final row will contain the bottom clues for the . columns. All values will be separated by a single space. Each line of data in the file will end with a newline/carriage return (m). There will be no trailing lines in the file. Another example that has two skyscrapers (the first one is valid but the second one) For each skyscraper read from the input file your program should first print that skyscraper, but with a space before the clues for the columns. There should NOT be spaces between any of the clues or skyscraper building heights. After printing the skyscraper you should print either the word VALID if the clues for that skyscraper were met or the words NOT VALID otherwise. VALID or NOT VALID (ALL CAPS REQUIRED) should occur on the line immediately following the skyscraper and should be followed by a newline/carriage return (In). Based on the second example input file above your output should look like this: 32213132412214321423132341222133VALID12343132412214321423132341222133 NOT VALID COMPLETED PROCESSING SKYSCRAPERS Note: the first and last line of each skyscraper have a space in front. In the Skyscraper class, you will need to provide at least three methods as following

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_2

Step: 3

blur-text-image_3

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions