Question
Programming 2 What Color is That Square? File names: color_square.py, chessboard.py, test_squares.py Positions on a chess board are identified by a letter and a number.
- File names: color_square.py, chessboard.py, test_squares.py
Positions on a chess board are identified by a letter and a number. The letter identifies the column; the number identifies the row. See the image below.
You will provide the functions that allow us to determine:
- if a chessboard square is either black or white, given its coordinates.
- If the row/column is valid or not for the standard chessboard
For example, if we pass in d for the column and 4 for the row, your function that determines color should return thestring:BLACK.If we pass in "k" for the column to your function that validates columns, that function should return theboolean False.
Requirements:
- Your function for validating the column should be able to accept upperorlowercase strings as parameters.
- Your functions for validating the row should be able to accept integersorstrings as parameters.
- Your function that determines black-or-white may assume that the input has been validated prior to us calling it (that is aprecondition) and should return the string "BLACK" or "WHITE" based on the row/column values passed in
- You must provide three helper functions. Twoof those functions:
- check_valid_row( row ) and
- check_valid_column( column )
must be defined in the file chessboard.py: Thethirdfunction: black_or_white(row, column) must be defined in the filecolor_square.py
- check_valid_row and check_valid_column both return abooleanTrueif the row or column passed in is valid,Falseif not. Remember to define these functions in a chessboard.py. We will run auto-tests on these functions, so be sure to name them properly and place them in the correct files.
- You must write test function for check_valid_row() and check_valid_column(). Your test functions should validate a few "normal" scenarios as well as one or two "out of bounds" situations for the rows and columns. You may name your test functions whatever you wish, but you must define them in a file namedtest_squares.py. In this same file, also include a function calledtest_squares()that acts as the "test driver" and calls your two test functions. Our auto-grader will use this function to interact with your test suite. You have flexibility in how you present your test results, but conciseness and ease-of-readability (or lack thereof) will influence your grade. Here's an example of what you might consider producing:
Your grade for this part of the assignment will be based on your solution code, your test functions provided and our own test suite, as well as manual inspection of your solution code for other rubric items (documentation, efficiency, etc.).
No main() is required for this assignment.
Resources: You might find the built-inord()andchr()functions, as well as an ASCII table of characters helpful for this part of the assignment.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started