CSE5APG-Semester 2, 2021Assignment 2Build a Naughts and Crosses game1 Assignment requirements Due: 11:55pm, 16/10/2021 This is an individual assignment, and it covers 25% of the final mark forCSE5APG. Your work should be submitted by the due date online via the LMS. All submissions will be checked by TURNITIN plagiarism software . Anycopy-paste will be referred to LTU academic integrity. So please avoidcopy-paste from other or any website. You should write a piece of code for each process. Do not MANUALLYadd, delete, or make any sort of calculation.2 Assignment descriptionThe Assignment 2 will test your understanding and ability to apply whatyou have learnt throughout the lectures. Python basics Data structures Function OOP Exception HandlingNaughts and Crosses game (aka Tic-Tac-Toe) is a well-known and very simple two-player game. The game consists of a playing grid (3×3 or higher) andtwo players. The playing grid has a set of squares. The squares will be filledby the players. The two players are known as the Naughts player which will be1detonated as ”O” and the Crosses player which will be denoted as ”X”. Theplaying rules are : The Naughts player plays with ”O”. The Crosses player plays with ”X”. Players take turns by placing ”O” or ”X” on the playing grid square. Only one player can play at a time- either ”O” or ”X”. The player makes their selection by entering the location of grid squarethey want to go (the square they want to fill). If any of the two players have filled a grid square, then the other playerand the same player cannot filled that square. If any player gets three of their marks (”O” or ”X”.) on the board in arow, column or one of the two diagonals, this player will be the winner. When the playing grid square fills up with neither player winning, thegame terminates with no winner.3 Steps you must completePlease see and run attached code: test.py . You need to convert test.py into anew code using: function, OOP and exception handling. The code should askthe user to key-in the size of playing grid (e.g., 3×3, 6×6, ..etc). For example,current grid and final should be printed using function. In addition, invalidinput should be handled. You need to develop three main classes: Board,Player, GameState. Each class must be implemented and tested. It is expected that your program can accept various grid sizes, so all input should beset automatically based on the gird size. You must use the same names forclasses (Board, Player, GameState) and functions.The main steps are:1. Once you run the program, the user will be prompted with a menu.2. The user will need to enter their choice.3. The choice will be to either begin the game, or quit.4. If the user enters an invalid choice, the user should be prompted appropriately letting them choose once more.5. The program should not end unless the user chooses otherwise.26. If the user begins the game, the game will be terminated if one player winthe game or all playing grid square have been filled up with neither playerwinning.3.1 Main MenuIn the main menu, the user will be prompt with a menu consisting two choices. Begin the game Quit the gameThis will menu will be printed out to the screen.Pseudo Codeprint (“introduction message”)print (“choices for the user”)3.2 User enter choiceThe user will enter their choice. Which will result in the following. Begin game should prompt with The game has begun then return tothe main menu. The quit game, should break out of the loop and stop the program.Pseudo Codeuserinput = input(“ask user to input”)3.3 Check User InputThe users choice should be checked to see if it is valid. If not then throws acustom error.Pseudo Codeif invalid input:raise InputValidError()3.4 Throw custom error if user input is invalidPlease implement a custom error. This custom error should be caught be a trycatch error.3Pseudo Codeclass InvalidInputError(Exception):pass4 Overview of flow of codePseudo Code# 1. Prompt the user with the main menuwhile True: # 2. Infinite loop until user exits.if check if user quits:# 2. if the user quits, break out of loopelif is choice valid:# execute users choice# back to main menuelse:raise InvalidError()5 Classes InformationThe Assignment 2 will consist of developing three main classes: Board,Player, GameState.NoteHelper classes can be designed to support the 3 main classes. Theseclasses will not be graded. These support classes do not have to betested.6 The MainBelow is a detailed UML diagrams explaining how the classes are related toeach other. They are for explanation purpose. You can add any parameters orfunctions.NoteThe UML diagram is a guide. If you wish to design your structure, youmay do so.46.1 Overview of class relationship ≪Main≫main BoardGameState Player7 Board7.1 Relationship Board– display board(board: list)+ check board(board: list, gameover: bool) 7.2 Board ClassPseudo Codeclass Board:def display_board(board):passdef check_board(board, gameover):pass8 Player8.1 Relationship Player– interaction(board: list)+ update board(board: list, gameover: bool) 58.2 Player ClassPseudo Codeclass Player:def __init__(self, symbol):passdef _interaction(self):passdef update_board(self, board):passdef __str__(self):pass9 GameState9.1 Relationship GameState– interaction(board: list)+ update board(board: list, gameover: bool) 9.2 GameState ClassPseudo Codeclass GameState:def __init__(self, p1, p2):passdef turn(self, board):passdef place(self, player, old_board):passdef game_loop(self, board):pass6
- Assignment status: Already Solved By Our Experts
- (USA, AUS, UK & CA PhD. Writers)
- CLICK HERE TO GET A PROFESSIONAL WRITER TO WORK ON THIS PAPER AND OTHER SIMILAR PAPERS, GET A NON PLAGIARIZED PAPER FROM OUR EXPERTS
