2ME3 - Assignment 1 Please read this document very carefully. Follow instructions exactly. If you have...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2ME3 - Assignment 1 Please read this document very carefully. Follow instructions exactly. If you have any questions please post them to MS Teams or ask during office hours. This assignment is due Oct 17th, by 11:59pm I have created an Assignment 1 channel in Teams. If you have questions about the assignment, please post them there. Thank you. Unless specifically stated, assume you are not allowed to import external libraries. Purpose This assignment will have you implement a partially implemented Connect Four game. It should highlight the OO principles of encapsulation, inheritance, and polymorphism. If you are unfamiliar with Connect Four please read this article: https://www.wikihow.com/Play-Connect-4 Overview There are three Java files which accompany this document: 1. ConnectFour.java 2. Player.java 3. Board.java You are responsible for submitting three Java files: 1. Board.java 2. HumanPlayer.java 3. AIPlayer.java See below for details on what you are responsible for completing. How To Begin Read through ConnectFour.java, specifically, read and understand the playGame () method. This is where the high level logic and flow takes place. As you will see, this method is not complete due to Player.java being an abstract class. Study how these classes use/relate to each other and what has access to what. You may need to deduce a few things about the final implementation. The end goal of the game is to be have something as follows. If the below code was executed: public static void main() { } Board board = new Board(); ConnectFou game = new ConnectFour (board); game.setPlayer 1 (new HumanPlayer ('R', board, "Alice")); game.setPlayer2(new HumanPlayer('B', board, "Bob")); game.playGame(); then something similar to below would be output to the console. Of course, depending on user input things could vary. |_|_|_|_|_|_|_| It is Alice's turn. Alice, please input your move: 3 | | | | | | | | |_|_|R|_|_|_|_| It is Bob's turn. Bob, please input your move: 3 | | |B| | | |_|_|R|_|_|_|_ It is Alice's turn. Alice, please input your move: 4 | | | | | | | | |B |_|_|R|R|_|_|_| It is Bob's turn. Bob, please input your move: 4 | | | | |B|B| | | |_|_|R|R|_|_|_| It is Alice's turn. Alice, please input your move: 2 | | |B|B| | | |_|R|R|R|_|_|_| It is Bob's turn. Bob, please input your move: 5 | | |B|B| | |_|R|R|R|B|_|_| It is Alice's turn. Alice, please input your move: 1 | | | | | |B|B| || |R|R|R|R|B|_|_| "Congratulations Alice, you have won!" Your Tasks 1. Create and implement two classes: HumanPlayer.java and AIPlayer.java. Both of these classes should extend Player.java and not be abstract. That is, they will need to implement the method makeMove. See the points below for information on the two different implementa- tions. For HumanPlayer, the makeMove method should prompt the user for input. You can assume the user will always input a number between 1 and 7 inclusive. However, if the user inputs an invalid move, i.e. that column is full, you should reprompt the user for a valid input. For AIPlayer.java, the makeMove method can do whatever you want as long as the following two criteria are met: If there is one or more winning moves available, the AI player will make one of them. If there is no winning move available, but their opponent has one or more winning moves available for next turn, the AI player will block one of them. If you wish, you may import java.util.Random for this method. 2. Complete the implementation of the Board class to function as described in the How To Begin section. For the printBoard () method, do not worry too much about it being exactly as seen in this document, but it should be intuitive and human readable. You will need to have some sort of internal representation of the board within the class. How you choose to store the board state is up to you. However, this decision in no way should be exposed to any other classes. For example, if you choose to use a 2d array to store the board state, all the Player classes should not be exposed to array notation/methods in any way. In other words, if you decided to change your implementation from an array to an ArrayList, the only class you should need to modify is Board.java. To achieve this, you will need to add some methods which are not yet declared. If you wish, you may import external libraries for your internal board representation. For example, ArrayLists. Submitting and Grading This assignment will be submitted electronically via Avenue. Part of your assignment will be auto graded, part will be done manually. A rough breakdown is as follows: HumanPlayer: 20% AIPlayer: 30% Board methods: 30% Board encapsulation: 20% Good luck! Additional Notes You may import java.util.Scanner in the HumanPlayer class. Some of the interactions between the object are intentionally designed in a somewhat awkward way to get a point across. One of the main challenges you will need to address is how the AIPlayer will know if a move blocks a win without knowing the other player's symbol. You may assume during a game, both players will always have different symbols. For testing your game, you should use code similar to that found earlier in this document, i.e. create a Runner class with this code in it: public static void main() { } Board board = new Board(); ConnectFour game = new ConnectFour (board); game.setPlayer 1 (new HumanPlayer('R', board, "Alice")); game.setPlayer2 (new HumanPlayer('B', board, "Bob")); game.playGame (); Academic Dishonesty Disclaimer All of the work you submit must be done by you, and your work must not be submitted by someone else. Plagiarism is academic fraud and is taken very seriously. The department uses software that compares programs for evidence of similar code. Please don't copy. The TAs and I want you to succeed and are here to help. Here are a couple of general guidelines to help you avoid plagiarism: Never look at another assignment solution, whether it is on paper or on the computer screen. Never show another student your assignment solution. This applies to all drafts of a solution and to incomplete solutions. If you find code on the web that solves part or all of an assignment, do not use or submit any part of it! A large percentage of the academic offenses in involve students who have never met, and who just happened to find the same solution online. If you find a solution, someone else will too. 2ME3 - Assignment 1 Please read this document very carefully. Follow instructions exactly. If you have any questions please post them to MS Teams or ask during office hours. This assignment is due Oct 17th, by 11:59pm I have created an Assignment 1 channel in Teams. If you have questions about the assignment, please post them there. Thank you. Unless specifically stated, assume you are not allowed to import external libraries. Purpose This assignment will have you implement a partially implemented Connect Four game. It should highlight the OO principles of encapsulation, inheritance, and polymorphism. If you are unfamiliar with Connect Four please read this article: https://www.wikihow.com/Play-Connect-4 Overview There are three Java files which accompany this document: 1. ConnectFour.java 2. Player.java 3. Board.java You are responsible for submitting three Java files: 1. Board.java 2. HumanPlayer.java 3. AIPlayer.java See below for details on what you are responsible for completing. How To Begin Read through ConnectFour.java, specifically, read and understand the playGame () method. This is where the high level logic and flow takes place. As you will see, this method is not complete due to Player.java being an abstract class. Study how these classes use/relate to each other and what has access to what. You may need to deduce a few things about the final implementation. The end goal of the game is to be have something as follows. If the below code was executed: public static void main() { } Board board = new Board(); ConnectFou game = new ConnectFour (board); game.setPlayer 1 (new HumanPlayer ('R', board, "Alice")); game.setPlayer2(new HumanPlayer('B', board, "Bob")); game.playGame(); then something similar to below would be output to the console. Of course, depending on user input things could vary. |_|_|_|_|_|_|_| It is Alice's turn. Alice, please input your move: 3 | | | | | | | | |_|_|R|_|_|_|_| It is Bob's turn. Bob, please input your move: 3 | | |B| | | |_|_|R|_|_|_|_ It is Alice's turn. Alice, please input your move: 4 | | | | | | | | |B |_|_|R|R|_|_|_| It is Bob's turn. Bob, please input your move: 4 | | | | |B|B| | | |_|_|R|R|_|_|_| It is Alice's turn. Alice, please input your move: 2 | | |B|B| | | |_|R|R|R|_|_|_| It is Bob's turn. Bob, please input your move: 5 | | |B|B| | |_|R|R|R|B|_|_| It is Alice's turn. Alice, please input your move: 1 | | | | | |B|B| || |R|R|R|R|B|_|_| "Congratulations Alice, you have won!" Your Tasks 1. Create and implement two classes: HumanPlayer.java and AIPlayer.java. Both of these classes should extend Player.java and not be abstract. That is, they will need to implement the method makeMove. See the points below for information on the two different implementa- tions. For HumanPlayer, the makeMove method should prompt the user for input. You can assume the user will always input a number between 1 and 7 inclusive. However, if the user inputs an invalid move, i.e. that column is full, you should reprompt the user for a valid input. For AIPlayer.java, the makeMove method can do whatever you want as long as the following two criteria are met: If there is one or more winning moves available, the AI player will make one of them. If there is no winning move available, but their opponent has one or more winning moves available for next turn, the AI player will block one of them. If you wish, you may import java.util.Random for this method. 2. Complete the implementation of the Board class to function as described in the How To Begin section. For the printBoard () method, do not worry too much about it being exactly as seen in this document, but it should be intuitive and human readable. You will need to have some sort of internal representation of the board within the class. How you choose to store the board state is up to you. However, this decision in no way should be exposed to any other classes. For example, if you choose to use a 2d array to store the board state, all the Player classes should not be exposed to array notation/methods in any way. In other words, if you decided to change your implementation from an array to an ArrayList, the only class you should need to modify is Board.java. To achieve this, you will need to add some methods which are not yet declared. If you wish, you may import external libraries for your internal board representation. For example, ArrayLists. Submitting and Grading This assignment will be submitted electronically via Avenue. Part of your assignment will be auto graded, part will be done manually. A rough breakdown is as follows: HumanPlayer: 20% AIPlayer: 30% Board methods: 30% Board encapsulation: 20% Good luck! Additional Notes You may import java.util.Scanner in the HumanPlayer class. Some of the interactions between the object are intentionally designed in a somewhat awkward way to get a point across. One of the main challenges you will need to address is how the AIPlayer will know if a move blocks a win without knowing the other player's symbol. You may assume during a game, both players will always have different symbols. For testing your game, you should use code similar to that found earlier in this document, i.e. create a Runner class with this code in it: public static void main() { } Board board = new Board(); ConnectFour game = new ConnectFour (board); game.setPlayer 1 (new HumanPlayer('R', board, "Alice")); game.setPlayer2 (new HumanPlayer('B', board, "Bob")); game.playGame (); Academic Dishonesty Disclaimer All of the work you submit must be done by you, and your work must not be submitted by someone else. Plagiarism is academic fraud and is taken very seriously. The department uses software that compares programs for evidence of similar code. Please don't copy. The TAs and I want you to succeed and are here to help. Here are a couple of general guidelines to help you avoid plagiarism: Never look at another assignment solution, whether it is on paper or on the computer screen. Never show another student your assignment solution. This applies to all drafts of a solution and to incomplete solutions. If you find code on the web that solves part or all of an assignment, do not use or submit any part of it! A large percentage of the academic offenses in involve students who have never met, and who just happened to find the same solution online. If you find a solution, someone else will too.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
JST204 Self Reflection Pro-forma INSTRUCTIONS FOR COMPLETION: You must submit this completed pro-forma for assessment 3, JST204. No other submission is required, only this pro-forma. You must watch...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-6. On December 12, Irene purchased the building where her store is located. She paid...
-
Carol Harris, Ph.D, CPA, is a single taxpayer and she lives at 674 Yankee Street, Durham, NC 27409. Her Social Security number is 793-52-4335. Carol is an Associate Professor of Accounting at a local...
-
A tank of water of length 2 0 m , 1 0 m , and height 5 m is filled with water of density 1 . 2 g / cm 3 . Find the pressure ( in Pa ) of water on one of the walls at a point 5 9 cm above the bottom.
-
In each part, find z1z2, z12, and z22 (a) z1 = 3i, z2 = 1 - i (b) z1 = 4 + 6i, z2 = 2 - 3i (c) z1 = 1/3 (2 + 4i), z2 = 1/2 (1 - 5i)
-
Exercises 3134 concern the Markov chain model for scoring a tennis match described in Section 10.1, Exercise 35. Suppose that players A and B are playing a tennis match, that the probability that...
-
Acetic acid is extracted from water with isopropyl ether at \(20^{\circ} \mathrm{C}\) and 1 \(\mathrm{atm}\) pressure in a column with three equilibrium stages. Equilibrium data are in Table 13-7....
-
The bookkeeper for Geronimo Company has prepared the following balance sheet as of July 31, 2008. The following additional information is provided. 1. Cash includes $1,200 in a petty cash fund and...
-
Corporate Social Responsibility. Design an ideal Corporate Social Responsibility response and strategy to the following social issue. Imagine you were the principal of school like Braemar College....
-
Rachel Cook is very concerned. Until recently, she has always had the golden touch, having successfully launched two start- up companies that made her a very wealthy woman. However, the timing could...
-
Explain how High-Frequency Traders (HFT) negatively affect market liquidity? Explain in detail so that it is easy to understand.
-
A company reports the following information for its direct labor. Actual hours of direct labor used Actual rate of direct labor per hour Standard rate of direct labor per hour Standard hours of...
-
1. Create a MOD 6 counter using sequential circuits using JK flip flops for the sequence given as { 0,2,4, 1, 3,6]
-
4. Find two nonnegative numbers whose sum is 9 and the product of one number and the square of other number is maximum. 1 3 3 Q5. Find the Adjoint and inverse of 143 1 3 4
-
What is the output of the following code if score is 90.? if (score >= 60.0) System.out.println("D"); else if (score > 70.0) System.out.println("C"); else if (score >= 80.0) System.out.println("B");...
-
How did the development of the computer impact the Cognitive Psychology Movement? How do you believe the Cognitive Psychology Movement would have been impacted if the computer had not been developed
-
1. Will the following code output the correct statements about x = 5? If not, why is the code incorrect? X = 5 if x < 6: print('x is less than 6') if x > 6: print ('x is larger than 6') else: print...
-
5. How much would you need to deposit in an account now in order to have $5,000 in the account in 5 years? Assume the account earns 2% interest compounded monthly. 10. You deposit $300 each month...
-
Ken paid the following amounts for interest during 2012: Qualified interest on home mortgage...........................................$4,700 Auto loan...
-
On July 1, 2012, Ted, age 73 and single, sells his personal residence of the last 30 years for $365,000. Ted's basis in his residence is $35,000. The expenses associated with the sale of his home...
-
Harold Conners (Social Security number 785-23-9873) lives at 13234 DeMilo Drive, Houston, TX 77052, and is self-employed for 2012. He estimates his required annual estimated tax payment for 2012 to...
-
Use the working papers and data from On Your Own 15-2. Forms for completing this On Your Own are provided in the Working Papers. Work independently to complete this problem. 1. Assume Cheries Pizza...
-
Milford Pump Company's income statement has been prepared for November of the current year. Instructions: 1. Prepare Milford Pump Companys November income statement reporting contribution margin. 2....
-
Dennis Williams is projecting the coming years net income potential for Williams Paint. The paint is sold for \($15.00\) a gallon. Variable costs per gallon are \($10.00\), and annual fixed costs are...
Study smarter with the SolutionInn App