Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

During the process of writing code, the programmer is deeply immersed in the problem, the algorithms and code to solve it and has that context

image text in transcribedimage text in transcribedimage text in transcribed
During the process of writing code, the programmer is deeply immersed in the problem, the algorithms and code to solve it and has that context when naming methods, variables, and writing comments. Looking at someone else's code, or even your own code 6 months later can be challenging since the names and comments weren't necessarily written to guide someone new to the problem and code. This assignment's code works, but some methods have poorly chosen names, formatting, and comments. The objective is to format it, reduce redundant code, improve the naming and commenting to help guide someone like yourself, that is new to the code and problem, through it. Play the game, add additional print statements to learn about the contents of the variables, and use the debugger to systematically step through the code. This code works but there are some problems that need to be corrected. Your task is to complete it to course style and documentation standards CS 200 Style Guide. This project will be human graded, see the grading rubric below. Getting Started Set up a ConnectFour project in your IDE (Eclipse or lntelliJ) . Download ConnectFour.java and TestBenchConnectFourjava . Make sure both files compile and run. . Note: The provided code compiies and runs, but there is a bug in the method isWinningCoord. The 903! is to x this bug, and refactor, improving the code and ensuring that it is working. - Add a file header comment to both files. . Turn in both les to zyBooks to make sure all the tests pass. Style and Format each ofthe methods . Format the method code to follow course standards. The lDEs can be helpful, but review to make sure the standards are followed. 0 ln Eclipse, select code, go to the Source menu, select Format, and then select Correct Indentation (Alternatively: Ctrl + Shift + F} o In lntelliJ, select code (in editor, Ctrl + A), go to Code menu, select Reformat Code (alternatively: Ctrl + Alt + L) . Verify your program is still working. 0 Turn into zyBooks to verify your program is still working. Turning in also saves snapshots of your code to return to at a later time if necessary. If at any time your program is not working, then back up to a point it was working and try again. Refactor the identiers (names) Specically the methods: isWinningCord, comp, pg b. The naming aside from calls to these methods is correct. Refactor the method names, parameters, and local variables to be meaningful and follow course standards. 0 Meaningful names easily guide someone that is not familiar with the code to understand what the method does or what the variable contains. Variables are typically nouns or noun phrases while method names are typically verbs or verb phrases. Avoid abbreviations unless very commonly used. 0 l1 Eclipse or lntelliJ, rightclick on a variable name, select Refactor, select Rename. Type the nevi.r name and the name will be changed everywhere. (Alternatively in Eclipse Alt + Shift + R, IntellLJ Shift+F6) - Trace he code using any example inputs to figure out what is happening. 0 "race by hand. use print statements, or use a debugger. If you add print statements to help you debug, remember to remove them later. Verify your program is still working. 0 "urn into zyBooks periodically to verify your program is still working and also provide snapshots of your code to return to at a later time if necessary. Add Class and Method Header Comments, and Field Comments - Write a JavaDoc comment for the class and every method following the course standards. Method comments should include a summary description, an algorithm for nontrivial methods possibly including a citation. and @param and @return tags (ifthere is a return value) with a description. We expect you to use your own words. - Specifically, you need to add method header comments for main, isWinningCord, comp, and pgb. - Verify your program is still working. - Turn into zyBooks periodically to verify your program is still working and also provide snapshots of your code to return to at a later time if necessary. Bug Fix and Testing - There is a bug in the isWinningCord method. - Run the test bench and you will see the first test vector runs correctly [true is returned}, whereas the second test vector does not [false is returned). - Add four additional test vectors; they should be clearly distinct such as a horizontal test, the opposite diagonal, a situation that is not a winning coordinate, etc... . Correct the method code. . Tip: Use the unit test to help you debug and test the method. You can add more than just 4 additional tests. Notes . Some methods are given to you with correct code and method comments (checkFullBoard, get Token, drop Token, findWinning Move, isWinningCol). The code is correct in all methods except for the bug in isWinningCord. The only changes that would need to be made to these methods are if they call other methods whose names have been changed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions