首页 > > 详细

Java辅导:Programming Assignment 5辅导Java设计、Java程序讲解

Introduction
:
,,if(,),
,,
:
,,,,,
Requirement
Programming Assignment 5 ( 100 Points )
Due: 11:59pm Thursday, October 27th
README ( 10 points )
You are required to provide a text file named README, NOT Readme.txt, README.pdf, or README.doc, with your
assignment in your pa5 directory. There should be no file extension after the file name “README”. Your README should
include the following sections:
Program Description ( 4 points ) : Provide a high level description of your program. Describe what your programs
do and how you can interact with them. Make these explanations such that your grandmother or uncle or
someone you know who has no programming experience can understand what this program does and how to use
it.
Write your README as if it were intended for a 5 year old. Do not assume your reader is a computer science
major.
Short Response ( 6 points ) : Answer the following questions:
Vim related questions (keyboard commands only – no mouse actions, ASCII characters only):
1. In vim, how do you move the cursor to the end of a line with a single command? To the beginning of a line
with a single command?
2. How do you highlight/select a line in vim?
Java related questions:
3. What does the keyword static mean in regards to variables?
4. What does the keyword static mean in regards to methods? Provide an example use of a static method.
5. What is overriding? Give an example from a previous/current assignment.
Unix related questions:
6. Using the cut command, how do you extract out only the columns 5 through 13 in a file named foo?
STYLE. ( 20 points )
Please see previous programming assignments. A full file header for your README is not needed, but you still need to
put your name and cs11f login at the top. However, all other style. guidelines apply to all the files ( e.g. over 80
characters apply to READMEs as well. )
You will be specifically graded on commenting, file headers, class and method headers, meaningful variable names,
sufficient use of blank lines, not using more than 80 characters on a line, perfect indentation, no magic numbers/hard-
coded numbers other than zero and +/-1, and use of accessor/mutator methods to access private fields (getters and
setters) where specified.
CORRECTNESS ( 70 points )
You are asked to create an interactive 3 x 3 puzzle game for pre-schoolers. The player has to drag the puzzle pieces on
the right to the correct location on the left to form. a complete image. This assignment does NOT involve ActiveObjects
or require a paint() method. The correctness of this assignment is based on meeting the required functionalities listed
below.
Part 0: Overview BoardPieces PuzzlePieces
We have a 3 x 3 puzzle, which gives us 9 puzzle pieces that are movable on the right. They can be dragged
anywhere on the canvas, but not off the canvas. On the left, we have a 3 x 3 board. After a puzzle piece is dragged
onto its correct location, the puzzle piece is “locked” into the board and is no longer movable.
The reason “locked” is in quotes is because the puzzle piece is actually not locked. We created this illusion by
having two different types of Pieces here: PuzzlePiece and BoardPiece. When a PuzzlePiece (movable piece on the
right) is dragged onto a BoardPiece (fixed piece on the left), your program will do some verification to see if they
match. If so, it’s going to hide the PuzzlePiece and reveal the BoardPiece with the same image as the PuzzlePiece.
So it may seem like the PuzzlePiece is locked in place, but it’s actually a different BoardPiece that’s displayed on
the canvas. Now that we know the basic idea/hack behind this game, how do we implement it?
Part 1: Useful Interfaces
Take advantage of interfaces! We have two different kinds of Piece types here, but they share a lot in common.
We’ll implement the Piece interface later in PuzzlePiece and BoardPiece classes.
1. The Highlightable interface is used to draw borders and highlights around each piece:
import java.awt.Color;
public interface Highlightable {
public abstract void showHighlight( Color color );
public abstract void hideHighlight();
}
2. The Hideable interface is used to hide and show pieces:
public interface Hideable {
public abstract void show();
public abstract void hide();
}
3. The Piece interface, which extends the two interfaces above an⁣㱥⁡⼠㹦൥੷⸠ ♰㭢⁥⁲⁲⁰†⁲♩㭴⁥†⁨⁥⁤⁥㱢 ⼾㸍ഊੰ⁣⁥†⁳⁣⹴
䴻†Ɫ⁳⁣⁥†⁣⁢‾㱰⽩㹣ഠ੡⁡†⁴†⁃⸩㰻⁲⼠㸯ാ਍㍩㩣†⁡㰠⁴⽉㹤ന਩⁲☾㭬†⁴⁣⁤⁤⁤⁥ⰻ‼†  ⁩††⁵⸠⁣䍲㰠⁐⽩㹥ൣ੥⁥⁳⁤䍡⁐‼⠾⤍ †⁳†⁳†⁰䅬⹮䵴䙥⹣⁥㱴⁦⽡㹣൥ਮ⁸⁥‾⁰㝵㍢㕬⁩⁣㍬㡡び⁳⹐㱩⁥⼠㹩൭ੰ㍴㨠⁐䝩⁥䤠㱬⁰⼻㸠ൽ਼‾ㄍ《ぅ⁨⁐ㅩづっ⁣⁩⁳⁩⁴⁡⁩⁥⼼⹢⹲⼠⽵䅬㔻ⴠ⽩⹥⁣⁡
㱥⁡⽧㹥ഠ੣⁥〠⁦㡰⁡⡳⹩⹧†の⸠Ⱨ⁥ㅯ⹢ⱴ†♴㭣⥯⹮㱳⁵⽣㹴൯ੲ䤩⁢ ⁵†⁩⁥⁲Ⱐ‸†⁥䥦⡴⤠⁴⁴†⁴⡯⁥⁉䝄䥲⁥㰠⁥⽣㹥ഠ੷⁢⁳䍩⤯⸾‍䘊⁵㩮㱴†⼨㹡ഠੌ䥴⡯♢㭴ち⹴♰㭴⥳㬠㱴†⽣㹥൮ੴ†⁴⁦⁳㤠⁰⁢‍⁢䥵†⁲⡳⁨䥴⁵⥣⹥†䤨⁶㤠⁴⁧㰩⁡⽳㸠൯੮䥬⡆⥲ⱡ⁒†⁲⁨‼‾⁴⁦⁤⹧⁥䥤⡰⥳†⁳⁨䥥⁤⹡⁲㱥†⼨㹴൨੥†⁥†䥴⁲⁥
⁡⁆⁴⁢⁳⁲䉩⽯♥㬠⁦Ⱐ⁡㱴⁳⽱㹵൯਻⁳䉥⼠☊㬠⁲Ᵽ⁵䥥⁥⁦⁳⁲†䥂⁐⹨㱯⁤⼠㹯൮੬⁳㍰㩡⁹䰠㱵⁲⼼㹢൲ਠ ⁳⁲ ⁴⁣䉯⁦⁂⁤⁺⁥⁥⁨⁤⹥㱸⁰⽬㹥ഺ਼䅢Ⰽ ⁂⁲⁧ㅥ㠠⁩⁤Ɱ†⁣⁲⁃⁶⁣⁡⁨‼䱢Ᵽ⁨⁥㱣⁳⽳㸠൷੩䉬⁨⁥⹨⁥⁥⁡‮ …⁧⁧†⁤
㱡⁥⽳㹳ഠ੡䱮†⁶⁩⁦⁥⁡㩒㱥†⽯㹢൪੥⁴‍⁴䥥䕡䍣䕨䕥䌮䱢⁲㴠 ㌾㬍 ⼦⽢⁵†⁨†⁺⁣⁨㱨†⽴㹨൥ਠ⁢⁆⁥䥒䕥䍣䕴䕧⁴㴮†㍳㭨⽷⼨
†⁡‼††㱨†⽴㹨൥ਠ⁗†⁳⁈䱩䕧䄩䌠䥷䝥㴠⁷㉥〠㭷⁡⽮⽴†⁤⁰⁹⁥㰠‼⽢㹲ഠਯ⁣⁥⁩䱩䕳䙮䘠䕨†㵣㍲㕲㕥㭣⁴⼠⽳⁰⁴
††㱡⁲⼩㸮഼੢⁢⁨†⁐䉵䅺䑥䵩䅥䝥䤠⁵㵬⁤㈠㕨㭩⁤⽥⼠⁴⁤⁨⁩㱨†⽨㹩൤੥⁣⁳⁴䉨䅮䐠䵮䅬䝳䥳†㴯‾㐍《㭹⽵⼠⁰†⁥⁴㱴†⽣㹲൥੤ ⁩䥳䐨䔩䱩䕮䝐䡺⁺㵬⁥ㅐどづ㭣⁥⼠⽤⁥⁩⁥⁥㱮⁩⽳㸠ൣ੯䉮†⁖⁥⁥⁡㱤⁩⽴㹨഼੢†㴯‾䈍䅴䑡䴠䅰䝥䥣⁈⭩䤺䐠䕵䱥䔠䝩䡩⁢⡥╡⁧䤦䕲䍳䕱䕳䍯䱴⥡㱩
⼩㸠൭੥㱤†⽣㹯൮ੴ⁩㵮⁳䈨䄠䑥䵨䅯䜠䥩⭡⁲䥐䑩䕥䱥䔠䝥䡵⁩⁲⡥†⽡†䥩䕴䍴䕬䕲⥭⹯㱲⽯㹧൩੣⁥⁩⁩†⁺⁳㱥⁥⼬㸠൹੯†㵤䱱䕵䙴䘠䕡⁴⬠⁨䱥䕲䄠䍳䥯䝶⁥†⡴⁩╳†䥯䔠䍱䕵䕬䍢䰠⭵⁳ㅴ⤼㱢 ⼾㸍ഊ੤⭲⁡䥧䑩䕮䰠䕴䝥䡐⁵⁺⡺⁥═⁩䥣䕥䍳䔠䕳䍥䱯⥵㱧⁴⽯㸠൴੨㱯⁤⽐㹩൥੣⁳㴠⁳䱥䕹䅴䌠䥬䝣⁥⡤⁩⽮†䥵䕴䍯䕭䕣†⭉⁦ㄠ⥹⭵†䥲䑥䔼䱲䔠䜾䠊⁴⩨⁥⠠⽡⁹䥲䔬䌠䕹䕡⥯⹮㰦ⁱ⽵㹯഻ੴ††⁧⁥††⁐⁺⁩䥬†‍⁦⸠⁷⁩⁨⁲㱥‮⼠㹓൯ਠ††††☠㭤⁡⁩⁥⁣†⁥⸍㰊⁳⽳㹩൮੧䈠†††⁳†⁲Ⱐ⁰†⁨†⁥⁺⁥†♤㭮⁲ℍ☊㭮⁴
㴩‮㌠㕉㕦㰠⁥⼠㹣൥੮†⁦㴠⁴⁐⁺⁥†⁷⁡䈠⹰⁩䥸⁲†⁣⁲⁦㔠㕴⁨⁢‍⁡⹣⁥䠬⁥⁥㱹⽤㹱൵੯⁩⁩Ɐ…†⁂⁲⁩⁗⡨⁷†⁡⁥ ⁨⁨⁣㱥⽦㸠൴੨⁥⥮⹴㱡⁥⽤㸠൩੮⁥☠㭸⁳⁲⁩‮⸍ †⁡䉬††⹐⁩⁥ⁱ
†䥥⁥㱨⁐⽵㹺ൺ੬⁥䱣†⁴⁂䉯⹮‼†⁴⁤⁨†⁤⁥⁧⁵ⁱ⁄††㱡⁩⽧㹮൥੤䈠⹥⁣‼‾…⁧⁤䤨⁴⁴⁵⁵䱥⁴⁥‼ 䈦⁃⁴⹲⁥䕴㱳⁨⽥㸠ൣ੥䉮⁥䤠䑐⁩⁲…※⁩⁂⁤†⹤㰠†⽮㹯൴੨䙩†⁩Ⱳ⁥⁩†⁵⁡†⁡ ⹭⁥⁡⁦⁤⁥㱴†⽣㹲൥੤⁶†⡡⥲⁧†⁥⁡䱲⁣⁡䑷䌠⹥‮‼ ⁵㱲⁵⽺㹺൬੥䤠䝰⁨⁡ †ち⁲㡢⹪⁥⁤⁐‼†⁙㱨⁥⼠㹡൬੬⁳⁨⁣⁲♧㬮⁡⁢⹤⁲䥡‮Ⱳ‮⁲ ††⁹††⁥⁩㱩⁹⽯㹵ഠੰ†Ɐ⁴⁤⁨⁳⁩‮⸾‍☼㬍⁩⁹⁤ⱶ⁩㱴⁴⽯㸠൹੯⁨⁲⁣⁹⹥†⁩ †⁴⁲⁵⁹†⁧㱡⁩⽧㹮൭੥⁴⁡⹭⁥♡㬠†㥡⁳⁳⁵⁩ⸯ‾⁥⁤⁥䤠䑩⁳⁨⁷⁷†㱲‾⼍㸊ൖ੥‼ ⁶†⁶⁳⁵⁤⁳⸠㰯 ⼾㸠ൣੳ‱⁹⁢ ⁡㡳Ⱶ⁲⁰†⁡䵳䄠䴠䙲䥤䔠䍩䕮†⹶⁥䥲⁦Ɽ㰮⁥⼠㹷൩੬䵬䄠䵴䙥䥮䕹䌠䕬⁴⁦㥩⹬⁥⁵⁲ ⁲†⁵†‮ⱦ⁹⁩⁨⁰䴠䅹䵨䙫䥨䕩䍣䕨⁦♩㭯⁵ㄠⱨ⁡㱣⁳⽳㹦൵੬⁢⁥†⁩†⵩⁢⸠㱭⁥⼠㹳൵ੲ䡥ⅰ⁲⁲⁴⁩⁹⁡⁩⁥‼ 䈾†⁃  ⁣⹳†䈠⁡⁳⁩‼㰍⽡㹲൤੐⸼⁢‍䜊䥩⁤‼⡢ ⥧⁨‮⁶‾⁩‮⁢⁐⁡†‍⁥㱪⁡⼼㹢൲ਠ⸮⁲ ‮† ⹢⁲㨠⤯㰾⁰⼳㸮൪ੰ†㌯㨍 䑰⁲㰼†⼯㸾഍ਊ䉰‮䅰㕧ⰼ⁢‾⁰⁢⁰†⁁䵥⠾⤍Ⰺ⁒䵄䑲⠍⤊Ɐ⁢⁴䵡⠍⤊⹅⁸†⁴㰠⁰⽯㹩൮ੴ⁲‍⹥›⁥⁲⁎⁰⁲†⁥†††⁩⁰⁴⁣⁩㱥⁡⽭㹥ഠ੦⹡⁳⁥⁲ ⁧⁡⁳⁓⁹ⱹ⁒⁅⁲⁲⁴⁨⁦⁨⁲⹴㰠⁵⼠㹨ൡ੶⁲‍⁥†⁄⁧⁦⁩′⁴⁁⁲†⁨†㰬⁨⽥㸠ഹਠ⁲⹥㱳⁨⽯㹵൬੤㌠㩩⁥㰠†⽡㹥൲੩䡡♩㭕⁃‾⁄⁁††⁲⁩⁡†⁧⁩⡳⁤⁤⥵⁴⁣㱲⽬㹹ബਠ⁡†⁧⁴⁳⁲㼊‹♥㭥⁨††ⱨ⁡⁴䥯☠㭥⁨
⁤⡳䡩䥤㩂⁤⁥†䵳䑴⡲⥲⥹⸠㱡⁵⽴㸠൤ੲ䉡⁩䥮♧㭢 †⁶
⁵⁡⁩⁥⁡†⸼⁢†⁦Ⱐ⁗㱮⁧⼠㹛ലਮ†⁴‼ ⁥⁥⁴⁳⁵㕯〻⁴⁴㕯ば†⁧⁰⁺⁡⁡䈬Ⱳ†⁡⁲㰠⁴⼠㹡൬੷††‍☊㭲♥㭴⁨‮†䉭⁳⡩⁡⁡††⡣⥫⥩⹮⁧䠠ⱷ⁨†㱣⁰⽬㹥൴੥☠㭭⁥⁺†䉷⁲⁨…†⹴⁤†䍃⠩⤠⁡†⁡⁡㰠⁩⽮㹧൳ਠ‾⁤ⁱ⁴⁤⡩⥴⁩⁩⁥䈠⁡†⹔⁥䥸†‮⁣†⁨䉥㱡†⽳㹨൯ੵ‮††⁔⁓⁔⁐⁢䅲䐯‾⁁⁅‼⡢⁥䥬䑬⥰ⰻ⁡⁈⁅⁎  㰀 ⼀㸀ഀ਀☀㬀☀㬀  ⸀ 䄀Ⰰ  ☀㬀☀㬀㰀 ⼀㸀ഀ਀      㰀 ⼀㸀ഀ਀    䈀 㰀 ⼀㸀ഀ਀   ⸀ 䐀☀㬀㰀 ⼀㸀ഀ਀    㰀 ⼀㸀ഀ਀  䈀    ⴀ㰀 ⼀㸀ഀ਀   ☀㬀 㰀 ⼀㸀ഀ਀  ℀㰀 ⼀㸀ഀ਀ ㌀㨀  㰀 ⼀㸀ഀ਀䄀 ☀㬀 䤀      ℀ 䠀        㼀      㰀 ⼀㸀ഀ਀    ⸀             ☀㬀☀㬀⸀㰀 ⼀㸀ഀ਀     䤀䐀     㠀Ⰰ              㰀 ⼀㸀ഀ਀☀㬀☀㬀⸀             ⸀ 䄀    Ⰰ 㰀 ⼀㸀ഀ਀       䈀        㤀 ⸀ 㰀 ⼀㸀ഀ਀     ⸀㰀 ⼀㸀ഀ਀䄀 Ⰰ ☀㬀     ⸀㰀 ⼀㸀ഀ਀㰀 ⼀㸀ഀ਀    Ⰰ     㨀㰀 ⼀㸀ഀ਀㸀  ⴀ ⸀⼀

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!