Your Perfect Assignment is Just a Click Away
We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

Project 2 CSC-171 Skyscraper Puzzle

Project 2 CSC-171 Skyscraper Puzzle

Project 2 CSC-171 Skyscraper Puzzle

3/9/2021

1 Problem

Imagine a city block of skyscrapers whose area is surrounded by streets. Skyscrapers of various heights are evenly distributed into the rows and columns of the block. A skyscraper puzzle is one where you are asked to organize the skyscrapers into a valid configuration that meets all the criteria for the puzzle.

1.1 Puzzle Details

These game rules, along with sample puzzles, can be found at:

http://www.brainbashers.com/skyscrapershelp.asp

Figure 1: Skyscraper Rules

1

Figure 2: Skyscraper ”Clues” or ”Looking Values”

Figure 3: Skyscraper Puzzle Solution

1.2 Warmup

Try to solve the puzzle in the figure below – this part is just for fun!

2

2 Project Requirements

Although it would be a very fun exercise to write a program to solve skyscraper puzzles, for this project you are only asked to write a program to verify solutions.

You should design a Skyscraper class, with private variables representing the state (i.e., the board configuration) as well as the following methods:

1. public boolean verifyPlacement() – this method should return true if the place- ment is valid (i.e., every row and every column contains each number exactly once.). Otherwise, this method should return false.

2. public void loadPuzzle() – this method should read a puzzle from standard input in the format specified below. This method must update the relevant instance variables for the object.

3. public void print() – this method should print the puzzle to standard output fol- lowing the format specified below.

4. public void printWithVisibility() – this method should print the puzzle along with the visibility scores on the outside.

5. A very simple main method which loads the puzzle from the user, then checks validity and prints the result. If it’s valid, it also prints the puzzle with visibility.

Continued on next page.

3

2.1 Input and Output Format

The loadPuzzle() method reads the configuration from standard input. This is the format of the input and the required output for basic printing:

1. The first line contains the square dimension of the board, DIM, as a single integer. 2. The remaining DIM lines will each contain exactly DIM positive integers, separated by

a single space, but with no trailing space after the last integer. These lines represent the heights of the skyscrapers in the same layout as the puzzle.

3. All subsequent lines should be ignored.

For example, the puzzle in Figure 3 is described by the input:

4

4 3 2 1

1 4 3 2

3 2 1 4

2 1 4 3

2.1.1 printWithVisibility Format

The printWithVisibility method should output a graphical representation of the puzzle, along with the visibility scores calculated according to the rules described earlier.

For the puzzle in Figure 3, the output of this method should be:

1 2 3 3

——-

1|4 3 2 1|4

2|1 4 3 2|3

2|3 2 1 4|1

2|2 1 4 3|2

——-

3 3 1 2

2.2 Design and Documentation

You are required to have exactly the public methods described in this document. You are also encouraged (but not required) to have helper methods. (These may be particularly helpful when verifying the puzzle and when calculating visibility.) All your helper methods should be declared private. If you have any class variables, they must be declared private as well.

Because it complicates grading, you are not allowed to have any package declarations. In- cluding package declarations in your submission will cause you to lose points.

As with all Java programs, your program filename must match the public class exactly, therefore your program must be named Skyscraper.java and your class name must be named Skyscraper.

4

Please include a readme in this submission which describes the state of your code. If every- thing works, you can simply write that everything works. Otherwise, describe what does and does not work when you submit it. Your readme should be plain text – no docx, rtf, or pdf files please.

3 Grading

Your grade for this assignment will be based on the following criteria:

• 25% verifyPlacement • 20% loadPuzzle • 10% basicPrint • 25% printWithVisibility • 10% Design and Documentation.

3.1 Submission

Zip your solution program, Skyscraper.java, and a readme file and into a zip file named skyscraper_USERNAME.zip, where USERNAME is replaced with your actual username. This will help us to efficiently grade your submissions.

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: I'm Homework Free only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by I'm Homework Free are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. I'm Homework Free is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At I'm Homework Free, we have put in place a team of experts who answer to all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.