1 / 10

Thursday, February 7, 2013

Thursday, February 7, 2013. Project 1, Testing. Header Files. Most end with .h To use header file in program: ‘#include< header.h >’ Programmer can reuse code amongst files Can share declarations amongst several source files Including header file essentially copies contents into program

kiril
Download Presentation

Thursday, February 7, 2013

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Thursday, February 7, 2013 Project 1, Testing

  2. Header Files • Most end with .h • To use header file in program: ‘#include<header.h>’ • Programmer can reuse code amongst files • Can share declarations amongst several source files • Including header file essentially copies contents into program • Less-time consuming • <>: computer looks in standard library path (stdio.h) • “”: computer looks in same path as source file

  3. chess.h • Defines constants • Board • Pieces • Valid/Invalid Moves • Declares methods and parameters

  4. Project 1 • board.c • For the board and printing chess pieces on board • To print board, call print_boardfunction • chess.c • Main function calls move_loop that runs game • Prints board, alternately calls get_valid_move for each player • get_valid_moveprompts for move and callscheck_move which checks validity of move

  5. check.c • General • X-Y coordinates are valid • “from” and “to” are different squares • “from” contains piece of valid color • “to” does not contain piece of same color (can contain piece of opposite color – capturing)

  6. Notes • Queen • check_queen is valid if check_rook or check_bishop is valid! • No need to detect checkmate • Termination occurs at -1 -1 -1 -1 (IMPORTANT) • Required functions

  7. Test Vectors • < and > to redirect input/output to/from file • Automatic comparison, diff

  8. Test Vectors • Reminder: • Make sure output matches EXACTLY • Points will be deducted for errors, including formatting • Watch out for: • Extra spaces • Capitalization, punctuation

  9. Common Compiler Errors • “Incompatible implicit declaration” • Missing library (ie #include <stdio.h>) • “Error: expected ‘;’”… • Syntax error (missing semicolon, parenthesis) • Using printf’s, while tedious, can also be very helpful

More Related