Introduction基本思路:模拟打高尔夫游戏,根据题目要求可以把场地看成一个线性的,所有可以用if语句和对应的距离将场地分成不同的区域(水,沙土),击球的距离是根据选用的球杆来定的,不同的球杆击球有不同的效果,根据题目要求此处用高斯函数来决定击球的距离注意点:在此题里面变量比较多,用到的循环液会嵌套起来,逻辑不能混乱,在处理细节上面,比如计分,球落地的场地也要细心RequirementProgramming Assignment 5 ( 100 Points )Due: 11:59pm Thursday, October 27thREADME ( 10 points )You are required to provide a text file named README, NOT Readme.txt, README.pdf, or README.doc, with yourassignment in your pa5 directory. There should be no file extension after the file name “README”. Your README shouldinclude the following sections:Program Description ( 4 points ) : Provide a high level description of your program. Describe what your programsdo and how you can interact with them. Make these explanations such that your grandmother or uncle orsomeone you know who has no programming experience can understand what this program does and how to useit.Write your README as if it were intended for a 5 year old. Do not assume your reader is a computer sciencemajor.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 linewith 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 toput your name and cs11f login at the top. However, all other style. guidelines apply to all the files ( e.g. over 80characters 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 andsetters) 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 onthe right to the correct location on the left to form. a complete image. This assignment does NOT involve ActiveObjectsor require a paint() method. The correctness of this assignment is based on meeting the required functionalities listedbelow.Part 0: Overview BoardPieces PuzzlePiecesWe have a 3 x 3 puzzle, which gives us 9 puzzle pieces that are movable on the right. They can be draggedanywhere on the canvas, but not off the canvas. On the left, we have a 3 x 3 board. After a puzzle piece is draggedonto 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 byhaving two different types of Pieces here: PuzzlePiece and BoardPiece. When a PuzzlePiece (movable piece on theright) is dragged onto a BoardPiece (fixed piece on the left), your program will do some verification to see if theymatch. 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 onthe canvas. Now that we know the basic idea/hack behind this game, how do we implement it?Part 1: Useful InterfacesTake 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 and includes a few other methods:import objectdraw.;public interface Piece extends Highlightable, Hideable {public abstract boolean contains(Location point);public abstract boolean equals(Object o);public abstract Location getCenter();public abstract int getId();public abstract void move(double dx, double dy);}Part 2: Piece ClassesYou will create 2 Piece classes: class BoardPiece and class PuzzlePiece.Each of these classes will implement the Piece interface. For example:public class BoardPiece implements Piece { … }Each Piece class will hold the specifics about that piece:• the piece image (a VisibleImage created from passing an Image object to its constructor)• ID (integer indexed from 0 to 8 in order of left to right and top to bottom, each ID represents a piece witha distinct image)• center (a Location object that represents the center point of this piece)• borders/highlights (PuzzlePiece (the movable pieces on the right) has one black FramedRect object righton top of the edge of the image and wraps around it as the border. BoardPiece (the fixed pieces on theleft) has two FramedRect objects, one right on top of the edge of the image, and one that’s inset by 1px,so it creates a thicker outline. When the game first starts, BoardPiece should only display the outerhighlight as black.)Thus, the constructor for BoardPiece and PuzzlePiece should be identical. For example:public BoardPiece(Image img, int id, Location loc, DrawingCanvas canvas) { … }Each Piece class will also implement the methods from the Piece interface.• showHighlight() and hideHighlight() can access and change the visibility of the FramedRect objects thathighlight each piece.• show() in PuzzlePiece should show the image and the black FramedRect highlight. show() in BoardPieceshould just show the image. We will call showHighlight() when we want to display the green highlight toindicate the puzzle piece is in the correct spot on the board (more on this later).• hide() in PuzzlePiece should hide the image and the highlight. hide() in BoardPiece does nothing unlessyou plan to implement the extra credit.• contains() in PuzzlePiece determines whether some point is contained in the VisibleImage associated withthat piece (Hint: use VisibleImage’s contains() method). contains() method in BoardPiece requires a littlemore logic. If you are giving this puzzle to someone, you don’t want him/her to solve this so quickly by justdragging the PuzzlePieces close enough to the BoardPieces so they get locked in automatically. If you arethe player, you also don’t want to be forced to drag the PuzzlePiece so your cursor/PuzzlePiece fallsperfectly within the BoardPiece. So what we are going to do here is add a different check: instead ofpassing the point where the cursor is, we are going to pass the center of the PuzzlePiece we are draggingto contains(). If the center of the PuzzlePiece is within a 50 by 50 pixels square in the center of theBoardPiece, then we can say “the point is contained” in the BoardPiece. What we are really checking hereis whether the center of the PuzzlePiece is contained in the 50 x 50px square in the BoardPiece.• equals() checks if two Pieces are equal (for example, does the PuzzlePiece match with the BoardPiece inthe board grid?). This is done by checking the unique ID (0 - 8) we assigned to each piece.• getId() returns the unique ID of the Piece.• getCenter() returns the center of the Piece.• move() in BoardPiece should do nothing since BoardPieces are fixed. You would have to add someimplementation if you decide to do extra credit. move() in PuzzlePiece is in charge of moving thePuzzlePiece around. There’s one tricky thing about this method… you need to make sure that thePuzzlePieces cannot be dragged off the canvas. More specifically, the center of PuzzlePiece should not beable to move off the canvas.Part 3: class PuzzleNow we’ve set up the building blocks for this game, we can start implementing the controller Puzzle class. ClassPuzzle should extend WindowController and include main() that starts a new instance of Acme.MainFrame. Thecanvas size should be 735 by 380 pixels.Part 3a: Get ImagesNine 100px x 100px puzzle piece images are available for you in ~/../public/PA5-images/. They are numberedfrom p0 to p8 (e.g. p0.jpg, p1.jpg, …).In order to load these images into the program, use the getImage() method in class Puzzle (the main GUI controllerthat implements WindowController). For example:getImage(“p0.jpg”);We need to load 9 images into an Image array (array of Image objects). Instead of hardcoding 9 lines ofgetImage(), we can do this in a loop using some string concatenation. getImage() will return an Image object. Youshould pass each Image object as an actual argument to each the of Board/PuzzlePiece’s constructor, and insidethat Board/PuzzlePiece’s constructor, make a VisibleImage object based on the Image object.Part 3b: LayoutThe main Puzzle class will also layout the BoardPieces and the PuzzlePieces as seen in the earlier screenshots.Again, instead of hardcoding 18 different locations, we are going to use two arrays to store Locations, one forBoardPieces and one for PuzzlePieces. The good news is that the constants and the formulas of calculating theseLocations have been worked out for you:private static final int PIECES_PER_COL = 3; // can be changed to expand the puzzleprivate static final int PIECES_PER_ROW = 3; // can be changed to expand the puzzleprivate static final int PUZZLE_SPACING = 20; // num of px between PuzzlePiecesprivate static final int PUZZLE_OFFSET = 355; // offset from left side of canvasprivate static final int BOARD_MARGIN_X = 25; // left margin of the boardprivate static final int BOARD_MARGIN_Y = 40; // top margin of the boardprivate static final int SIDE_LENGTH = 100; // side length of each PieceBoardPiece with index i is located atx = BOARD_MARGIN_X + SIDE_LENGTH (i % PIECES_PER_COL)andy = BOARD_MARGIN_Y + SIDE_LENGTH (i / PIECES_PER_ROW).PuzzlePiece with index i is located atx = PUZZLE_OFFSET + PUZZLE_SPACING (i % PIECES_PER_COL + 1)+ SIDE_LENGTH (i % PIECES_PER_COL)andy = PUZZLE_SPACING (i / PIECES_PER_ROW + 1) + SIDE_LENGTH * (i / PIECES_PER_ROW).These x and y coordinates represent the upper left corners of the VisibleImage in each Piece. You can check themath if you are curious what’s up with all these mods and divides.Before you place all the Pieces onto the canvas, add a Text object as the winning message “YOU WON!” at x = 355and y = the Y value of the fourth BoardPiece. It should have font size of 55 in bold and green. Hide the winningmessage for now, and we will come back to it later (the order of creation matters here because it affects thedrawing arrangement).Now let’s put the Pieces onto the canvas. Placing the BoardPieces is easy. We already have the Image array andthe Location array for BoardPieces. We just need another array of the interface type Piece to keep track of theBoardPieces. We will go through the Image array and the Location array and create BoardPieces in order. EachBoardPiece ID should match with its index in the Piece array.For PuzzlePieces though, we want to pick one of the nine images randomly. We can do so by implementing amethod called getRandomPuzzlePiece() that takes in Location and DrawingCanvas. This method will use aRandomIntGenerator that randomly generates an integer between 0 and 8. We will first check if this randomlygenerated index represents an image that’s already used. If so, we want to get another random index until we findan unused one, because every PuzzlePiece should have a unique image. Once we’ve found an unused index, wecan create a new PuzzlePiece. We are going to return this Piece we randomly created and store a reference to it ina Piece array. We’ll do this 9 times to place all the PuzzlePieces. Note that the ID in PuzzlePiece is NOT associatedwith its random array index but with the unique piece image.To avoid using magic numbers like 8, you can create a MAX_NUM_OF_PIECES constant. In our case,MAX_NUM_OF_PIECES is 9. When we need to use this as an index, we can do MAX_NUM_OF_PIECES – 1, whichtakes care of the offset from zero-based indexing.Hooray! Now you should be able to see all the BoardPieces and PuzzlePieces on your canvas. But we are not quitethere yet. Your GUI controller (class Puzzle) needs to handle all the mouse events and the logic of verifying thePieces. Take a break before you proceed. :)Part 3c: Dragging PuzzlePieceBy PA5, you should be pretty familiar with onMousePress(), onMouseDrag(), and onMouseRelease(). The logic isstill the same. You want to keep a reference to lastPoint and find the difference between lastPoint and currentpoint. You do need to do one additional thing here, and that is keep track of which PuzzlePiece is being grabbed.You can do so by looping through the Piece array holding all the PuzzlePieces and find which PuzzlePiece containsthe point.Part 3d: Verifying PuzzlePieceHmmm… Where should you be checking if the puzzle piece has been placed (not while still dragging) in the correctspot on the board to the left? There’s only one place, and I’ll let you answer it (HINT: it is NOT in onMouseDrag()).But I’ll walk you through how to verify a puzzle piece has been placed correctly. Remember many words ago, wesaid if the center of the PuzzlePiece is within a 50 by 50 pixels square in the center of the BoardPiece, we can saythe PuzzlePiece is “contained” in the BoardPiece (this check is already done in contains()). Here, the methodsyou’ve implemented in BoardPiece and PuzzlePiece come in handy. You can use getCenter() to get the center ofthe grabbed puzzle piece and call contains() on every BoardPiece in a loop. If we were able to find a BoardPiecethat contains the center of the grabbed puzzle piece AND they are equal (matching IDs), then we can go ahead and“lock” this Piece. Again, the “locking”is done by hiding the grabbed puzzlepiece and showing the BoardPiece asdescribed in the overview. Don’tforget to show green highlightsaround the BoardPiece to let the pre-schoolers know that they’ve placedthe Piece correctly!Part 3e: Verifying VictoryAlmost there… I can hear the sound of victory! How can we check if the puzzle is finished? One easy way to do thisis having yet another array. This array will contain booleans that represent whether a Piece has been “locked”.Since the Pieces have unique IDs from 0 to 8, we can just use those as indices and mark them true as they get“locked”. The game is done after every element in this boolean array becomes true. At the moment of victory, youshould hide the green highlights around each BoardPiece and display a seamless image composed of 9 pieces. Youshould also show the winning message.And yaaaaaay, that’s the end of this assignment.RunningTo compile your Puzzle game, type this into the terminal:> javac -cp ./Acme.jar:./objectdraw.jar:. Puzzle.javaTo run your Puzzle game, type this into the terminal:> java -cp ./Acme.jar:./objectdraw.jar:. PuzzleYou must have all the files in the pa5 directory including Acme.jar and objectdraw.jar.Do not have any other .java source files in you pa5 directory other than the ones required for this assignment.TurninTo turnin your code, navigate to your home directory and run the following command:> cse11turnin pa5You may turn in your programming assignment as many times as you like. The last submission you turn in beforethe deadline is the one that we will collect.VerifyTo verify a previously turned in assignment,> cse11verify pa5If you are unsure your program has been turned in, use the verify command. We will not take any late files youforgot to turn in. Verify will help you check which files you have successfully submitted. It is your responsibilityto make sure you properly turned in your assignment.Files to be CollectedSource Files Images Misc.BoardPiece.javaHideable.javaHighlightable.javaPiece.javaPuzzle.javaPuzzlePiece.javap0.jpgp1.jpgp2.jpgp3.jpgp4.jpgp5.jpgp6.jpgp7.jpgp8.jpgAcme.jarREADMEobjectdraw.jarExtra Credit ( 5 points )Note: There are NO separate extra credit files for this assignment. Implement the extra credit in the same files as theregular assignment. Specify in your README Program Description which parts of the extra credit you haveimplemented.1. Dragging after Winning [2.5pts total]After the user has finished the game, the 9 BoardPieces should look like a complete image of an aerial view of UCSan Diego. As a part of extra credit, enable dragging this “image” around the canvas (really, you are dragging these9 pieces together). You will have to change the move() method inside BoardPiece. Don’t worry about dragging theimage off canvas (you can always resize the canvas and get it back).2. Clicking after Winning [2.5pts total]The pre-schoolers just can’t stop playing your puzzle again and again, but their teacher is not always there torestart the game for them. To make it easier for them, add a feature so that clicking anywhere on the completeimage of the puzzle will restart the game. You’d want to add an onMouseClick() and reinitialize many things (Hint:You don’t need to reinitialize the Image array or the Text object). Clicking on the white space should do nothing.NO LATE ASSIGNMENTS ACCEPTED!START EARLY!…and HAVE FUN!本团队核心人员组成主要包括BAT一线工程师,精通德英语!我们主要业务范围是代做编程大作业、课程设计等等。我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全 汇编语言 硬件编程 软件设计 工程标准规等。其中代写编程、代写程序、代写留学生程序作业语言或工具包括但不限于以下范围:C/C++/C#代写Java代写IT代写Python代写辅导编程作业Matlab代写Haskell代写Processing代写Linux环境搭建Rust代写Data Structure Assginment 数据结构代写MIPS代写Machine Learning 作业 代写Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导Web开发、网站开发、网站作业ASP.NET网站开发Finance Insurace Statistics统计、回归、迭代Prolog代写Computer Computational method代做因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected] 微信:codehelp