{"id":273,"date":"2011-08-25T21:35:21","date_gmt":"2011-08-26T04:35:21","guid":{"rendered":"http:\/\/blogs.unsw.edu.au\/comp1400\/?p=273"},"modified":"2011-08-28T18:15:07","modified_gmt":"2011-08-29T01:15:07","slug":"lab-7-debugging","status":"publish","type":"post","link":"https:\/\/blogs.unsw.edu.au\/comp1400\/blog\/2011\/08\/lab-7-debugging\/","title":{"rendered":"Lab 7 &#8211; debugging"},"content":{"rendered":"<p>For this project you will be debugging a simple &#8216;games portal&#8217; program. You can download the program as a Bluej project <a href=\"http:\/\/www.cse.unsw.edu.au\/~cs1400\/labs\/\">here<\/a>. The code is complete and compiles correctly but it has a number of bugs in it that mean it doesn&#8217;t work properly. It is your job to find them.<\/p>\n<p>There are two classes <strong>Player<\/strong> and <strong>Game<\/strong>. A Player has a credit balance with which they can buy games. A player can play any game they own, generating a score. The game keeps track of the best score for every player who has ever played it.<\/p>\n<p>The methods on Player are:<\/p>\n<ul>\n<li><strong>getName<\/strong> &#8211; returns the player&#8217;s name<\/li>\n<li><strong>getCredit<\/strong> &#8211; returns the player&#8217;s current credit<\/li>\n<li><strong>addCredit<\/strong> &#8211; adds credit to the player&#8217;s account<\/li>\n<li><strong>buyGame<\/strong> &#8211; allows a player to buy a game if they have enough credit (and do not already own the game)<\/li>\n<li><strong>ownsGame<\/strong> &#8211; returns whether the player owns the game<\/li>\n<\/ul>\n<p>The methods on Game are:<\/p>\n<ul>\n<li><strong>getName<\/strong> &#8211; returns the game&#8217;s name<\/li>\n<li><strong>getCredit<\/strong> &#8211; returns the game&#8217;s purchase price<\/li>\n<li><strong>play<\/strong> &#8211; The specified player plays the game and gets a random score. If it is better than the player&#8217;s best score so far, it is added to the high-score list<\/li>\n<li><strong>getHighScore<\/strong> &#8211; get the best score for the specified player<\/li>\n<li><strong>getBestPlayer<\/strong> &#8211; return the player who has the top score for this game,<\/li>\n<\/ul>\n<p>There are at least <strong>seven bugs<\/strong> in the code. Three on Player and four on Game. You need to:<\/p>\n<ol>\n<li>Read the code and try to understand what it is doing.<\/li>\n<li>Invent test cases to check that it works the way it is supposed to.<\/li>\n<li>When you find something wrong, try to find the nearest possible cases that work and fail.<\/li>\n<li>Step through the different cases in the Debugger to work out what is going wrong.<\/li>\n<li>Work out how to fix them.<\/li>\n<\/ol>\n<p>Some of the bugs are trickier to find than others. Test the simpler parts of the code first, then work up to more difficult cases.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For this project you will be debugging a simple &#8216;games portal&#8217; program. You can download the program as a Bluej project here. The code is complete and compiles correctly but it has a number of bugs in it that mean it doesn&#8217;t work properly. It is your job to find them. There are two classes [&hellip;]<\/p>\n","protected":false},"author":80,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[630],"tags":[],"class_list":["post-273","post","type-post","status-publish","format-standard","hentry","category-lab"],"_links":{"self":[{"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/posts\/273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/users\/80"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/comments?post=273"}],"version-history":[{"count":2,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/posts\/273\/revisions"}],"predecessor-version":[{"id":275,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/posts\/273\/revisions\/275"}],"wp:attachment":[{"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/media?parent=273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/categories?post=273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/tags?post=273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}