Introduction基本思路:一共有两题第一题:判断读取文件是否是回文文件,根据题目定义理解什么事回文文件,用递归来判断一个单词是否是回文,再判断整个文件第二题:完成一个类似抽奖的游戏,给对应图片编号记录分数,根据最终摇到的图片的分数来计算选手的得分,最后得出胜负注意点:第一题:读取文件的时候会发生一系列IO异常,要仔细处理第二题:组件的位置要仔细调整,做出摇奖的动画比较麻烦,要然位置变化先慢后快再慢,得到滚动的效果RequirementProgramming Assignment 7 ( 100 Points )Due: 11:59pm Thursday, November 10thREADME ( 10 points )You are required to provide a text file named README, NOT Readme.txt, README.pdf, orREADME.doc, with your assignment in your pa7 directory. There should be no file extension after the file name“README”. Your README should include the following sections:Program Descriptions ( 5 points ) : Provide a high level description of what each of your programs do andhow you can interact with them. Make this explanation such that your grandpa or uncle or someone you knowwho has no programming experience can understand what these programs do and how to use them. Do notassume your reader is a computer science major.Short Response ( 5 points ) : Answer the following questions:Vim Questions:1. In vim/gvim, what commands will indent N consecutive lines (starting from the cursor line) by one levelwhere the indent level is defined to be two spaces? This will take two vim commands: one to set thenumber of spaces to indent with each indent level (default is 8), and one to actually indent Nconsecutive lines. Likewise what command will shift N lines left (de-indent N lines)?2. In vim/gvim, what command will indent an entire curly-bracket block one level, while the cursor iscurrently on either the open or close curly bracket of the block? Likewise what command will shift anentire curly-bracket block one level left (de-indent block)?3. How do you open a new line below and insert (one keyboard key for both steps)?Unix Question:4. On the Unix command line, how can you capture (redirect) the program’s output into a file named“output”?Java Question:5. How can you create an array of ints in Java and initialize it with the values of all single digit odd positivenumbers (inclusively between 0-9), all in one step/line?STYLE. ( 20 points )Please see preview programming assignments; especially PA2’s writeup. You will be specifically graded oncommenting, file headers, class and method headers, meaningful variable names, judicious use of blank lines,not having more than 80 characters on a line, perfect indentation, no magic numbers/hard-coded numbersother than -1, 0, +1, using setters and getters, etc (see the style. section of PA2’s writeup).You will lose significant points if you have static methods or static variables for the Spin100 program(except, constants are okay). Instead you should create getters and setters to change the variables for anobject.CORRECTNESS ( 70 points )Start by creating your pa7 directory as usual. Then copy over the starter code from the public folder by doingthe following:$ cp ~/../public/PA7indrome.java ~/pa7$ cp ~/../public/PA7-images/ ~/pa7Program 1: PA7indrome ( 20 Points )You must use recursion and implement the methods listed below or you will lose all 20 points for thisprogram. Also, do not edit the main() method in PA7indrome.java as it will negatively affect your grade.Write a command line application that checks whether an array of strings is a palindrome. A palindrome is aword, phrase, number, or other sequence of characters which reads the same forwards and backwards. Theprogram will take in a file as a command line argument. Each line of the file will be converted into a string,where each string will be placed as an element in an arraylist then converted to an array (this part has alreadybeen written for you in the main() method–do not edit anything in this method). Your task will be to thendetermine if the array of strings is a palindrome or not (non-case sensitive). You will be using two recursivemethods to implement this functionality.public static char[] reverse( char[] toRev ) {…}● Overall goal: reverse the array of characters passed in using recursion.● If the length of the character array passed in is 1, just return the array right away.● Otherwise, swap the first and last characters in the array (#1-3 below)● Copy the middle of the array into a new array and recursively call reverse on this new array (#4 below).● Place the returned array back into the middle of the original array of characters, and return thisreversed array of characters (#5 below).● Hint: you can use System.arraycopy() (look up the javadocs).● This method must use ends-and-middle recursion.public static boolean isPalindrome( String[] words, int lo, int hi ) {…}● Overall goal: determine if the array of strings passed in is a palindrome using recursion.● Determine if the string at the low index in the words array is the reverse of the string at the high index inthe words array. To do so, you must use your reverse() function, after converting the string to a chararray and passing it in. This comparison should be non-case sensitive.● If the string at the low index is indeed the reverse of the string at the high index, recurse on theremaining middle portion of the array by passing modified values of the low and high index in therecursive call. Otherwise, return false.● This method must use ends-and-middle recursion.You must use these methods as they are defined above or you will lose points.We will test for edge cases when grading this assignment, so it is up to you to test your program thoroughly.Similar to previous assignments, your output MUST match exactly to our sample output!Sample Output 1: Not a palindrome (user input in BOLD)For this example, the input file is named notPalindrome. If you open the file in vim, it should look like this:startearlystartoftenThe output from running PA7indrome will give you the following:[cs11fxyz@ieng6-201]:pa7$ java PA7indrome notPalindromeInput array of strings:start, early, start, oftenThe file is not a palindrome.[cs11fxyz@ieng6-201]:pa7$Sample Output 2: Odd-length palindrome (user input in BOLD)Input file named oddPalindrome:StArTEaRlYsTaRtoFtEnufotofuNeTfOTrAtSyLrAetRaTsThe output from running PA7indrome will give you the following:[cs11fxyz@ieng6-201]:pa7$ java PA7indrome oddPalindromeInput array of strings:StArT, EaRlY, sTaRt, oFtEn, ufotofu, NeTfO, TrAtS, yLrAe, tRaTsThe file is a palindrome.[cs11fxyz@ieng6-201]:pa7$The sequence of characters in the array of Strings generated from the input file reads the same forwards andbackwards (non-case sensitive), so it is a palindrome. Note that because the length of the array is odd, themiddle string must also be a palindrome (in this case the middle string is “ufotofu”, which is a palindrome).Sample Output 3: Even-length palindrome (user input in BOLD)Input file named evenPalindrome:StArTEaRlYsTaRtoFtEnNeTfOTrAtSyLrAetRaTsThe output from running PA7indrome will give you the following:[cs11fxyz@ieng6-201]:pa7$ java PA7indrome evenPalindromeInput array of strings:StArT, EaRlY, sTaRt, oFtEn, NeTfO, TrAtS, yLrAe, tRaTsThe file is a palindrome.[cs11fxyz@ieng6-201]:pa7$Sample Output 4: Palindrome with new lines (user input in BOLD)Input file named newLinesPalindrome. Note: New lines will be cut off (ignored) by the scanner.StArTEaRlYsTaRtoFtEnNeTfOTrAtSyLrAetRaTsThe output from running PA7indrome will give you the following:[cs11fxyz@ieng6-201]:pa7$ java PA7indrome newLinesPalindromeInput array of strings:StArT, EaRlY, sTaRt, oFtEn, NeTfO, TrAtS, yLrAe, tRaTsThe file is a palindrome.[cs11fxyz@ieng6-201]:pa7$Program 2: Spin100 ( 50 Points )You are to design a game that models itself after the mini game found in the Price is Right.Main idea of the game:● There are two players: Player 1 and Player 2. Player 1 gets to spin the wheel first. Player 1 gets tospin until they have reached over 100 points or have clicked the “Finish Player 1” button. At that point,it becomes Player 2’s turn. Player 2 then gets to spin until they have reached over 100 points or haveclicked the “Finish Player 2” button.● Once Player 2 goes over 100 points or clicks the “Finish Player 2” button, the game ends.● Whichever player is closer to 100 points wins. Once a player goes over 100 points then they’ve lost. Ifboth players go over 100 points then it’s a tie. If both players have the same score, then it’s a tie.Example scores and their outcomes:Player 1 70 120 20 100 100 95Player 2 90 110 120 100 105 100Winner Player 2 Tie Player 1 Tie Player 1 Player 2Implementation Details:This program will have two Java source files: Spin100Controller.java and Spin100Wheel.java.Spin100Controller.java will be the main controller which extends WindowController and handles the GUIlayout. Spin100Wheel.java will be the actual wheel object that defines what a wheel can do, how it spins, etc.1. Setting up the GUI:Start by first getting the GUI set up in the begin() method of Spin100Controller.java.The top panel will have 3 labels:● “Spin100” - You can customize the font of this label–don’t worry about whether the font is the default ornot! Just make sure your program doesn’t throw errors or have an incorrect layout / text upon start.● “Player 1’s score: “ - followed by player 1’s score (initially 0).● “Player 2’s score: “ - followed by player 2’s score (initially 0).○ Note the space following the ‘:’ for each player’s scoreThe bottom panel will have 5 buttons: (make sure the text matches exactly).● “Click to Spin P1”● “Finish Player 1”● “Restart”● “Click to Spin P2”● “Finish Player 2”The wheels on the center canvas:● The center of the window will have the canvas, similar to PA6. The height and width of the canvasshould be 840 x 660. Note that the canvas will not be resized during testing. On the canvas we willbe displaying two wheels (one for each player). In order to create the wheels, we need to initialize anarray of Image(s), using the images you copied over from the public folder. Make sure your imagesare directly inside your pa7 directory, and not in a subdirectory called PA7-images.● You will want to load the 20 images into an array of Images. To ensure you arrange the images in thecorrect order, we suggest creating the following array. This will ensure you load the images in thecorrect order and will also be helpful for scoring later on. Load the images corresponding to thesescore values in the order in which they appear in the array. The array of images and the array of scorevalues will be parallel arrays.private static final int[] SCORES = { 50, 85, 30, 65, 10, 45, 70, 25, 90, 5,100, 15, 80, 35, 60, 20, 40, 75, 55, 95 };● The wheel should always start with 50 in the center and should spin in a downward direction. Thismeans that when the wheel spins for the first time, the red arrow will first point to 50, then 85, then 30,and so on.● You will want to create each wheel by calling the Spin100Wheel constructor. Some parameters you willprobably want to pass to the constructor are:○ The array of Image(s) corresponding to the SCORES values.○ Location of the wheel (location of the top number). The center of the left wheel should behorizontally aligned with the center of the left half of the canvas. In other words, you need to findthe x-coordinate that will center the left wheel in the center of the left half of the canvas.Similarly, you need to find the x-coordinate that will center the right wheel in the center of theright half of the canvas. The y-coordinate of the top number for both wheels should be 10 (makesure the layout of your wheels matches the screenshots exactly).○ Reference to the Spin100Controller so that controller methods can be called from the wheel(this will be useful for setting the score after the wheel stops spinning each time)○ Reference to the drawing canvas so the wheel can be placed on the canvasThe red arrows on the center canvas:● The arrows are red-filled arcs with start angle = -15, arc angle = 30, height = 150, and width = 150.● Left arrow position: (234.5, 186.0)● Right arrow position: (688.5, 186.0)Messages declaring winner on the center canvas:● Create a hidden text object saying “Tie” at position (444, 5). The text should be blue, bold, and size 16.● Create a hidden text object saying “P1 Winner” at position (20, 5). The text should be green, bold, andsize 16.● Create a hidden text object saying “P2 Winner” at position (808, 5). The text should be green, bold,and size 16.See the screenshot section below to see what all of this looks like.2. Wheel FunctionalityBecause the wheels are animated, the Spin100Wheel class needs to extend ActiveObject (and therefore mustcontain a run() method).Creating a wheel:● Each wheel needs an array of 5 VisibleImages (generated from the array of images passed in as aparameter to the constructor) to store the 5 images that will be visible on the canvas at any given time.● The location passed to the constructor is the location of the topmost VisibleImage. The nextVisibleImage will be 99 pixels below that, and the next 99 pixels below that, and so on.● Each wheel needs a random double generator object to generate random numbers for the amount ofticks to spin when the spin button is clicked (see more details below in the Spinning the wheel section).● Don’t forget to save a reference to the Spin100Controller object to help with scoring.● Set the number of ticks to 0, so the wheel begins stationary.● As with all ActiveObjects, the last statement in the constructor should be start();.Spinning the wheel:● Initially, the wheel’s number of ticks should be set to zero. When a wheel’s spin button is clicked, thecontroller should update the number of ticks so the wheel will start spinning. This means you will wanta method to generate a random number of ticks for the wheel to spin.● One way to implement this is to have a method called getRandomTicks(). This method should:○ First generate a random double between 0 and 1○ Based on the random number, return the minimum number of ticks (50) + a number ofadditional ticks, which indicates how many ticks a wheel should spin for. This is to allow thewheel to stop on different numbers each time by randomizing where a wheel stops cyclingthrough the array of images.○ If the random number is between 0 and 0.05, return MIN_TICKS + 1. If it’s between .05 and .1,return MIN_TICKS + 2. You should keep adding one more tick until you return MIN_TICKS + 13for when the value is between .6 and .65. From there you should subtract one less tick until youreturn MIN_TICKS + 6 when the value is between .95 and 1.■ Range of ticks to add (over the .05 increments) is(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 12, 11, 10, 9, 8, 7, 6)● After getting the random number of ticks, the controller needs to set the wheel’s number of ticks using asetter method.● To make the wheel actually spin, the run method will need to constantly check its number of ticks. Ifthe number of ticks is greater than 0, increment the index of each visible image displayed to the nextindex in the images array; in other words, for every tick, shift the images down one. Once you reachthe last index of the images array, wrap back around to the beginning (Hint: think mod operator).Then decrement the number of ticks left for this wheel to spin and pause to slow down the animation.● At the beginning of each spin, the initial delay should be set to 1. Then when the wheel delay is lessthan 20, the wheel delay should increment by 1 on every iteration of the forever loop. When the wheeldelay is greater than or equal to 20 and less than 200, the wheel delay should increment by 5. Whenthe wheel delay is greater than or equal to 200 and less than 500, the wheel delay should increment by20. This will give the illusion of a faster spin at the start which eventually slows down and stops oncethe number of ticks is zero.● Once the number of ticks is 0, the wheel needs to call a public method in controller to let the controllerknow that the wheel’s score has changed and that the Text object for the score needs to be updated.● Some additional methods to include in the class would be setters and getters for the ticks, delay, andscore. This is so that the controller can call these methods and change the wheel’s variables’ valueswhen something like the spin, finish, or reset button is pressed.3. Controller FunctionalityYou will implement Spin100Controller.java to handle creating the buttons and listening to actions performed onthe buttons.● Upon start, only the “Click to Spin P1” and “Restart” buttons should be enabled. So in your begin()method, in addition to setting up the layouts of the buttons, you should also disable the “Finish Player 1”button and all buttons associated with Player 2.● Once you have clicked “Click to Spin P1”, all buttons are disabled until the wheel stops spinning. Oncethe wheel stops spinning, update Player 1’s score. Now that you have spun Player 1’s wheel at leastonce, the “Finish Player 1” button should be enabled.● As long as Player 1’s score is less than or equal to 100, Player 1 can choose to continue spinning byclicking “Click to Spin P1” again, or click “Finish Player 1” to finish their turn. Once Player 1’s score isover 100, the controller will automatically finish the turn for Player 1.● Once Player 1 has finished, all of Player 1’s buttons are disabled and the “Click to Spin P2” button isenabled for Player 2 to start spinning. The spinning process follows the same condition as stated forPlayer 1.● Once Player 2 has also finished, all but the Restart button should be disabled. A game over messageshould be displayed. The message could announce a Tie, or announce that either Player 1 or Player 2won (see screenshots for detail).Summary of the buttons● The Spin buttons: The spin button disables itself when:○ The wheels are spinning○ The player’s score has passed 100○ The player has clicked finish after at least one spin● The Finish buttons: Each player’s finish button is disabled until they have spun at least once. It is alsodisabled when the wheel is spinning, as well as after they have finished their turn.● The Restart button: This button is always enabled except when a wheel is spinning. Once clicked:○ It changes the scores back to 0○ It resets the wheels so that 50 is at the center again○ The “Click To Spin P1” button is enabled again and the buttons are reset to the original state.Implementation Requirements for Button Event HandlingTo manage the behaviors of the 5 buttons, you must define 5 private member inner classes inside theSpin100Controller class. Use your notes from class as a reference.● Each private class must implement the ActionListener interface.● The ActionListener interface enforces that each class has the actionPerformed(ActionEvent e) methoddeclared and implemented.Having separate inner classes for each button is much better than handling all button events in oneactionPerformed() method. This is because there is a one-to-one relationship between buttons and listeners,resulting in cleaner code that is less prone to errors.Note: Remember to use getters/setters vs. directly accessing variables by name.4. Sample Screenshots:The start of the program. Bothplayer’s scores are set to 0,with the arrows pointing to 50.Only the buttons: “Click to SpinP1” and “Restart” are enabled.After Player 1 clicks “Click toSpin P1”, the score for Player1 is updated. The “FinishPlayer 1” button is nowenabled after 1 spin.Player 1 clicks “Finish Player1”, and now only “Restart” and“Click to Spin P2” buttons areenabled.Player 2 now clicks “Click toSpin P2”, the score for Player2 is updated. “Finish Player 2”button is now enabled after thefirst spin.After Player 2 clicks “FinishPlayer 2” The winner textappears. The only buttonenabled is “Restart”.This is the case when Player1’s score is over 100, thusPlayer 2 wins.In the case that Player 1’sscore exceeds 100, thebuttons “Click to Spin P1” and“Finish Player 1” areautomatically disabled,allowing P2 to begin.If both player’s scores exceed100, the game results in a tie.TurninTo turnin your code, navigate to your home directory and run the following command:> cse11turnin pa7You may turn in your programming assignment as many times as you like. The last submission you turn inbefore the deadline is the one that we will collect.VerifyTo verify a previously turned in assignment,> cse11verify pa7If 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 responsibility to make sure you properly turned in your assignment.Files to be collected:Note: You must turn in all the files necessary for your program to run, including the .jar files and .png files.Note: Also, if any exceptions are thrown in the terminal, you will lose points.Source Files: Image Files: Misc:PA7indrome.javaSpin100Controller.javaSpin100Wheel.java.png (20 of them) objectdraw.jarAcme.jarREADMEEC_Spin100Controller.java (extra credit)EC_Spin100Wheel.java (extra credit)Extra Credit ( 5 points )Setup: Create copies of your regular source files and name them EC_Spin100Controller.java andEC_Spin100Wheel.java.Along with the functionality listed below, you will need to change the size of the window if you are adding theextra buttons. Set the canvas width to 1000 and the canvas height to 660.Overall Wins: 1 PointKeep track of the overall wins with a message that appears at the end of the game:Overall Wins P1: #, P2 @where # is a non-negative number indicating how many times player 1 has won the game and @ is a non-negative number indicating how many times player 2 has won the game. This message cannot overlap eitherwheel and it should be horizontally centered between the wheels. It should be 200 pixels above the verticalcenter of the canvas. The message can be in whatever color you would like besides black. In the case of a tie,neither player’s win count should change.Change Spin Direction: 1 PointAdd some new buttons and change the old ones so that each player has the option to spin up or down. Thereshould be a “P1, Spin Up” button, “P1, Spin Down” button, “P2, Spin Up” button, and “P2, Spin Down” button.To clarify, spinning up is where the numbers appear to be moving up (so the 50 goes towards the top) whereasspinning down is where the numbers appear to be moving down (so the 50 moves towards the bottom). Youcan see the new buttons in the screenshots below. Disabling the buttons should still work the same as it doesin the normal portion of the PA, just make sure to disable both the Up and Down spin buttons.Switch Starting Players: 3 PointsThe “Switch” button is enabled only at the start of each round of the game. This button should be disabled inthe middle of a game (i.e. if a spin has occurred). This allows the player who spins first to switch with the otherplayer. For instance, if Player 1 was going to start first and the switch button is clicked. then the game willrestart and Player 2 will now start first. If the restart button were then clicked, Player 2 would still be going first.Sample Screenshots:If all extra credit features are implemented, this is the initial state of the program.The overall number of wins for each player is shown when a round finishes.Player 2 can begin the round of a game when “Switch” is clicked.本团队核心人员组成主要包括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