” S5001课程程序 写作、 辅导Java编程设计程序CS5001 Object-Oriented Modelling, Design ProgrammingPractical 2 Animal ChessDue Friday, week 5 weighting 35%In this practical, you will be provided with an object-oriented model, and your task will be to implement it in Java. Themodel is specified by two things: a UML class diagram showing the required classes, and a suite of tests that definehow your program should behave. The details of implementation are up to you: after creating the classes in Java, youwill need to fill in their methods yourself, and decide on any additional fields, methods, classes etc. that you mightneed in order to meet the requirements.For this practical, you may develop your code in the IDE or text editor of your choice, but you must ensure all yoursource code is in a folder named CS5001-p2-animal-chess/src/animalchess, where animalchesscorresponds to the package name required by the specification.Animal ChessThe game of chess reached Japan from India around one thousand years ago, and over the centuries it developedrather differently in Japan From the rest of the world. The games focus switched towards pieces that move only onesquare at a time, and curious innovations arose, including a more complex system of promotions, and the ability todrop a captured piece onto the Board with its colour changed. The most popular chess variant in Japan today isknown as Shogi, or The Game of Generals; it has gained popularity over the years, and now has a significant numberof players outside the country.The subject of this practical is Goro-Goro Dobutsu Shogi (or Purring Animal Chess), a small Shogi variant designed byprofessional Shogi player Madoka Kitao, her aim being to introduce children to Shogi. The game is played on a 56board, and features four different animals which all move in different ways, with similarities to pieces found in chess.CS5001 Object-Oriented Modelling, Design ProgrammingMichael Torpey cs5001.lec@cs.st-andrews.ac.uk October 2020 2The two players sit facing Each other, with eight pieces each: a lion, two dogs, two cats and three chicks. Players taketurns moving a single piece. A chick moves one space forward.S5001课程作业 写作、 辅导Java编程设计作业 A dog moves one space forward, backward, left or right, or diagonally forward (6 directions). A cat moves one space in any diagonal direction, or directly forward (5 directions). A lion moves one space in any direction, either orthogonal or diagonal (8 directions).These directions are shown on the playing pieces with red dots.A player cannot move a piece onto one of their own pieces, but they may move onto one of their opponents pieces,in which case the opponents piece is captured. The capturing player takes the piece into their hand, and on a futureturn, instead of moving a piece, they may drop a captured piece, by placing it onto any empty space on the board asone of their own pieces. A player wins by capturing their opponents lion.The chick and cat pieces are promotable. If a player moves a chick or a cat into the farthest two rows from them (thetwo rows closest to their opponent) then it promotes. After promoting, on future turns, it moves like a dog. In a realgame, this is shown by flipping the piece over to show the picture on the other side.The official rules are available on StudRes here, and you should read them carefully before starting. However, notethat for this practical you may ignore the following rules: Two chicks annot normally be dropped on the same rank (dont worry about this). A chick drop that causes Checkmate is normally banned (dont worry about this). The same board state occurring 4 times normally results in a draw (dont worry about this). When a piece enters the promotion zone, its player normally chooses whether to promote (but you shouldjust promote it every time).More information about the game is here: httpss://en.wikipedia.org/wiki/D%C5%8Dbutsu_sh%C5%8Dgi#Variation.System SpecificationYou are required to implement the classes shown in the following UML class diagram, including all the public methodsand attributes shown. Your program should not require any input from the user, nor print any output to the screen.Your code can be tested by running the JUnit tests that are included with this practical. This can be done on the labmachines using stacscheck, by navigating into your CS5001-p2-animal-chess directory and running thefollowing command:stacscheck /cs/studres/CS5001/Practicals/p2-animal-chess/testsThis will compile your classes and run all the provided tests on them. You can access stacscheck on the lab machinesvia SSH, or if you use a Linux or Mac machine, you can install it on your own computer.Important: The behaviour we want from the system is defined by these tests. If youre not absolutely sure what aclass or method is supposed to do, you should look at the tests that correspond to it and examine the examples andassertions there. The relevant Unit test files are in subdirectories of the tests/ directory, and they all have names ofthe form classnameTest.javaYou can add to these by creating your own additional tests if you wish. You can run your own JUnit tests in an IDE, viathe command line, or via stacscheck. If an aspect of the programs behaviour is not defined by the tests or the UMLdiagram, you should make your own choice about what the program should do, and document this in your code as acomment.CS5001 Object-Oriented Modelling, Design ProgrammingMichael Torpey cs5001.lec@cs.st-andrews.ac.uk October 2020 3UML Class DiagramThis is the class structure of the system you should build. You should include every class and every public method onthe diagram, but you may implement more classes and methods if you wish, and the choice of private attributes andmethods is up to you.In this diagram, each yellow box is one class. The C symbol in the top part refers to a class, while the A symbol refersto an abstract class. Chick, Dog, Cat and Lion are all special types of Piece, so they inherit its public methods. Chickand Cat also inherit from PromotablePiece, which defines some special functionality for pieces that can promote.PromotablePiece and Lion show some methods marked with {override} this is a hint that you might want to overridethese methods in these particular classes. Each Piece is owned by one Player, and may sit on one Square (if it is not ina players hand). The whole Game has two Players, and 30 Squares (the 56 board shown above). When a playermoves a piece onto a square, they can use the squares isPromotionZone method to test whether their piece is in thezone where it promotes (the farthest two ranks from the player).Exception handlingAn exception of the class IllegalArgumentException should be thrown if a player tries to drop a piece that is not in theirhand, or if placePiece attempts to place a piece on a square that is already occupied. It may also be used in othersituations where an operation cannot be carried out because of an illegal argument. A short message describing whatwent wrong should be included in The exception. Make sure to catch it and handle it where appropriate!CS5001 Object-Oriented Modelling, Design ProgrammingMichael Torpey cs5001.lec@cs.st-andrews.ac.uk October 2020 4PackagesAlso shown on the UML diagram is the name of the package into which your classes should be placed: animalchess.Your .java files should be placed in the corresponding subdirectory inside your src/ directory. You should make sureto declare this package at the top of each file, with the line package animalchess;BehaviourA player has an attribute playerNumber, which should be either 0 or 1. Player 0 sits at the top of the board, and player1 sits at the bottom of the board. Each Square has a position on the board defined by its row and col attributes: theseshould be numbers between 0 and 5, as shown by the (row, col) pairs in the following diagram.Note that certain events, such as a piece being promoted, or a player winning, are triggered by public methods. Theseevents can be forced by calling the appropriate method for example, player.winGame() but should also betriggered according to the rules of the game for example, a player should win when they take their opponents lion.DeliverablesA report is not necessary for this project, but if you have strayed from the specification at all, or if you have made anydesign decisions that you wish to explain, you can include a short readme file in your CS5001-p2-animal-chess/ folder;this should include any Necessary instructions for compiling or running your program. Hand in an archive of yourassignment folder, including your src/ directory and any local test subdirectories, via MMS as usual.CS5001 Object-Oriented Modelling, Design ProgrammingMichael Torpey cs5001.lec@cs.st-andrews.ac.uk October 2020 5MarkingA submission which does not satisfy all the tests above may still receive a good grade. A submission that implementsall classes and methods as shown on the UML diagram, using object-oriented methods, but which does not have therequired behaviour in all cases, could receive a grade of up to 15 if it is implemented cleanly and intelligently.A submission which satisfies all the requirements described, including passing all the tests, can achieve any grade upto 20, with the highest grades awarded to implementations that show clarity of design and implementation, withadditional tests that show an insight into the problem.Any extension activities that Show insight into object-oriented design and test-driven development may increase yourgrade, but a good implementation of the stated requirements should be your priority.See the standard mark descriptors in the School Student Handbook: httpss://info.cs.st-andrews.ac.uk/student-handbook/learning-teaching/feedback.html#Mark_DescriptorsLatenessThe standard Penalty for late submission applies (Scheme B: 1 mark per 8-hour period, or part thereof) as shown at: httpss://info.cs.st-andrews.ac.uk/student-handbook/learning-teaching/assessment.html#lateness-penaltiesGood Academic PracticeThe University policy on Good Academic Practice applies: httpss://www.st-andrews.ac.uk/students/rules/academicpractice/如有需要,请加QQ:99515681 或邮箱:99515681@qq.com
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。