Project 2 CSC-171

专案2 CSC-171
摩天大楼之谜
3/9/2021
1个问题
想象一下一个摩天大楼的城市街区,其周围被街道包围。的摩天大楼
各种高度均匀地分布在块的行和列中。摩天大楼
拼图是要求您将摩天大楼组织成有效配置的一种方法
满足拼图的所有条件。
1.1拼图详细信息
这些游戏规则以及示例拼图可在以下位置找到:
http://www.brainbashers.com/skyscrapershelp.asp
图1:摩天大楼规则
1个
图2:摩天大楼的“线索”或“寻找价值”
图3:摩天大楼拼图解决方案
1.2热身
尝试解决下图中的难题–这一部分只是为了好玩!
2个
2项目要求
尽管编写解决摩天大楼难题的程序将是非常有趣的练习,但对于
这个项目只要求您编写一个程序来验证解决方案。
您应该设计一个Skyscraper类,使用代表状态的私有变量(即
板配置)以及以下方法:
1. public boolean verifyPlacement()–如果放置该方法,则此方法应返回true
是有效的(即每一行和每一列只包含每个数字一次)。
否则,此方法应返回false。
2. public void loadPuzzle()–此方法应从标准输入中读取一个难题
以下面指定的格式。此方法必须更新相关的实例变量
为对象。
3. public void print()–此方法应将拼图打印到以下标准输出中
下面指定的格式。
4. public void printWithVisibility()–此方法应打印拼图
外部的可见度得分。
5.一种非常简单的主要方法,从用户那里加载拼图,然后检查有效性
并打印结果。如果有效,它也会显示可见性的拼图。
接下页。
3
2.1输入输出格式
loadPuzzle()方法从标准输入读取配置。这是格式
基本打印的输入和所需的输出:
1.第一行包含板的正方形尺寸DIM,为单个整数。
2.其余的DIM行将分别包含正好为DIM的正整数,并由分隔
单个空格,但最后一个整数后没有尾随空格。这些线代表
与谜题布局相同的摩天大楼的高度。
3.所有后续行均应忽略。
例如,图3中的难题由输入描述:
4
4 3 2 1
1 4 3 2
3 2 1 4
2 1 4 3
2.1.1 printWithVisibility格式
printWithVisibility方法应输出拼图的图形表示,
以及根据前面所述的规则计算出的可见度得分。
对于图3中的难题,此方法的输出应为:
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设计和文件编制
您需要完全具有本文档中描述的公共方法。你是
还鼓励(但不是必需)使用辅助方法。 (这些可能特别
在验证拼图和计算可见性时很有帮助。)您的所有帮助方法
应该声明为私有。如果您有任何类变量,则必须将其声明为私有
也一样
因为它使分级变得复杂,所以不允许您使用任何程序包声明。包含
您提交的文件中的包裹声明会导致您丢分。
与所有Java程序一样,您的程序文件名必须与公共类完全匹配,
因此,您的程序必须命名为Skyscraper.java,并且您的类名称必须是
名为摩天大楼。
4
请在此提交中包含一个自述文件,以描述代码的状态。如果一切
有效,您可以简单地写出一切正常。否则,请描述其作用和
提交时不起作用。您的自述文件应为纯文本-不得为docx,rtf或pdf
请文件。
3评分
您为此作业的成绩将基于以下条件:
•25%verifyPlacement
•20%负载益智
•10%基本打印
•25%printWithVisibility
•10%的设计和文档。
3.1提交
将您的解决方案程序Skyscraper.java和一个自述文件压缩成一个名为zip的文件
skylineCSC-171程序设计代做USERNAME.zip,其中USERNAME被替换为您的实际用户名。这个
将帮助我们有效地对您的提交进行评分。


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 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.
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. 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.
4
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.
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.
Submit your zip file to Blackboard before April 1 2021 at 1159PM.

请加QQ:99515681 或邮箱:99515681@qq.com   WX:codehelp

上一篇:ERROR: ORA-28009: connection as SYS should be as SYSDBA or SYSOPER


下一篇:robot framework用法总结