联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Java编程Java编程

日期:2020-11-09 11:27

Project 2 CSC-171

Skyscraper Puzzle

10/21/2020

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

1.3 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 placement

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 following

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. See lecture

video Oct 26 for example usage.

Lastly, you are also required to write at least 3 test puzzles and to include them with your

submission. This is to encourage you to verify that your program is correct before turning it

in. Each test should be in a file named “test1.txt”, “test2.txt”, or “test3.txt”, respectively.

1.3.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. This will allow you to include comments at the

end of your test file that describe their purpose.

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

1.3.2 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.4 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. Including

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.

The TAs found your readme files for the first project to be extremely helpful – great job!

Please include a readme in this submission which describes the state of your code. If everything

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.

In both your readme file and your imlementation file please include your name and your UR

NetiD, as well as the name and NetID of your partner if you are not working alone. In the

implementation file this should be written using a comment. Due to the large class size, the

TAs had trouble with names alone, so including your NetID would be very helpful.

4

1.5 Grading

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

? 25% verifyPlacement

? 20% loadPuzzle

? 10% basicPrint

? 25% printWithVisibility

? 10% Test files (with descriptions).

? 10% Design and Documentation.

1.6 Submission

Zip your solution program, Skyscraper.java, along with a readme and your three test files,

test0.txt, test1.txt, and test2.txt into a single zip file named skyscraper_USERNAME.zip,

where USERNAME is replaced with your actual username. This will help us to efficiently

grade your submissions. Please be sure to use zip and rar (or other compression tools.)

Submit your zip file to Blackboard before November 11th 2020 at 1159PM.

1.7 Revisions

1. Oct 23. Fixed mistake in example visibility.

2. Oct 26. Specified main method, minor revisions to rubric, more detailed submission

instructions. Readme now required as well. This is expected to be the final revision.

5


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp