{"id":459,"date":"2012-10-07T19:04:49","date_gmt":"2012-10-08T02:04:49","guid":{"rendered":"http:\/\/blogs.unsw.edu.au\/infs1609\/?p=459"},"modified":"2012-10-07T19:04:55","modified_gmt":"2012-10-08T02:04:55","slug":"lab-week-12-uno-game","status":"publish","type":"post","link":"https:\/\/blogs.unsw.edu.au\/infs1609\/blog\/2012\/10\/lab-week-12-uno-game\/","title":{"rendered":"Lab Week 12 &#8211; Uno Game"},"content":{"rendered":"<p>Download the\u00a0<a href=\"http:\/\/www.cse.unsw.edu.au\/~cs1400\/lectures\/Uno.zip\">Uno Game<\/a> BlueJ project shown in the lecture.<\/p>\n<p><strong>Constructors<\/strong><\/p>\n<p>Use the debugger to watch how cards are constructed:<\/p>\n<ol>\n<li>Set a breakpoint in the WildDrawCard constructor (line 17).<\/li>\n<li>Create a new WildDrawCard by calling the constructor..<\/li>\n<li>Use the \u2018step into\u2019 button to step through the code. Observe how the\u00a0<code>super()<\/code> call works.<\/li>\n<li>Repeat this process for the other kinds of cards.<\/li>\n<\/ol>\n<p>Set up a game:<\/p>\n<ol>\n<li>Call\u00a0<code>Game.makeStandardDeck()<\/code> to create a deck (ArrayList) of cards.<\/li>\n<li>Press the\u00a0<strong>Get<\/strong> button to save this deck in a variable.<\/li>\n<li>Call the\u00a0<code>Game<\/code> constructor, providing this deck as a parameter.<\/li>\n<li>Call the\u00a0<code>deal()<\/code> method on the game you created to deal the cards.<\/li>\n<\/ol>\n<p><strong>Inheriting methods<\/strong><\/p>\n<ol>\n<li>Create a selection of cards from the different card classes.<\/li>\n<li>Right-click on each card to observe the methods it implements and the methods it inherits.<\/li>\n<li>Where is the\u00a0<code>canPlay()<\/code> method implemented on each card type?<\/li>\n<li>Where is the\u00a0<code>play()<\/code> method implemented on each card type?<\/li>\n<li>Set a breakpoint in\u00a0<code>WildDrawCard.play()<\/code> (line 26).<\/li>\n<li>Create a WildDrawCard and call its play() method. Use the debugger to step through the code.<\/li>\n<li>Observe the order the code is executed.<\/li>\n<\/ol>\n<p><strong>Add a new card type<\/strong><\/p>\n<ol>\n<li>Change the rule for the NumberCard so it can only be played on another NumberCard of value one more or one less that itself. (i.e. a 5 can be only played on a 4 or 6). Numbers should wrap around, so a 0 can be played on a 9 and vice-versa.<\/li>\n<li>Create a Transfer card class which transfers 2 random cards from the player to the previous player.<\/li>\n<li>Add a new Reverse-Draw card class which reverses the direction of play\u00a0<em>then<\/em>causes the next player to draw. Does it have any code in common with other cards? What class would it be best to inherit from?<\/li>\n<li>Create your own card types.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Download the\u00a0Uno Game BlueJ project shown in the lecture. Constructors Use the debugger to watch how cards are constructed: Set a breakpoint in the WildDrawCard constructor (line 17). Create a new WildDrawCard by calling the constructor.. Use the \u2018step into\u2019 button to step through the code. Observe how the\u00a0super() call works. Repeat this process for [&hellip;]<\/p>\n","protected":false},"author":345,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[236],"tags":[],"class_list":["post-459","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts\/459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/users\/345"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/comments?post=459"}],"version-history":[{"count":4,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts\/459\/revisions"}],"predecessor-version":[{"id":463,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts\/459\/revisions\/463"}],"wp:attachment":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/media?parent=459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/categories?post=459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/tags?post=459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}