{"id":141,"date":"2011-08-14T16:59:16","date_gmt":"2011-08-14T23:59:16","guid":{"rendered":"http:\/\/blogs.unsw.edu.au\/infs1609\/?p=141"},"modified":"2011-08-15T16:43:23","modified_gmt":"2011-08-15T23:43:23","slug":"tutorial-week-5","status":"publish","type":"post","link":"https:\/\/blogs.unsw.edu.au\/infs1609\/blog\/2011\/08\/tutorial-week-5\/","title":{"rendered":"Tutorial &#8211; Week 5"},"content":{"rendered":"<p>Your task this week is to implement a program to represent decks and hands of playing cards.<\/p>\n<ol>\n<li>Download the\u00a0<a href=\"http:\/\/www.cse.unsw.edu.au\/~is1609\/11s2\/tuts\/cards.zip\">cards.zip<\/a> file and uncompress it. It contains an incomplete BlueJ project called cards.<\/li>\n<li>Open the project and inspect the classes:\n<ul>\n<li><strong>Card<\/strong> \u2013 this represents a single playing card.<\/li>\n<li><strong>Deck<\/strong> \u2013 this represents a deck of cards. The constructor has been written but the methods need to be completed.<\/li>\n<li><strong>Hand<\/strong> \u2013 this represents a hand of cards drawn from the deck. The fields, constructor and methods all need to be implemented.<\/li>\n<\/ul>\n<\/li>\n<li>Complete these classes following the comments. Do the Deck class first then the Hand class.<\/li>\n<\/ol>\n<p>To complete the\u00a0<strong>Deck.draw()<\/strong> method you will need to use the\u00a0<a href=\"http:\/\/download.oracle.com\/javase\/6\/docs\/api\/java\/util\/Random.html\">Random class<\/a> in the Java API. This class provides a random number generator to pick random numbers.<\/p>\n<p>To use this class you will have to import it, by putting the line:<\/p>\n<p><code>import java.util.Random<\/code><\/p>\n<p>at the top of your code.<\/p>\n<p>Read the\u00a0<a href=\"http:\/\/download.oracle.com\/javase\/6\/docs\/api\/java\/util\/Random.html\">documentation<\/a> to find out what constructors and methods the Random class provide.<\/p>\n<p>To see what the class does, try typing the following into the Codepad:<br \/>\n<code><br \/>\nimport java.util.Random;<br \/>\nRandom rng = new Random();<br \/>\nrng.nextInt(6)<br \/>\nrng.nextInt(6)<br \/>\nrng.nextInt(6)<br \/>\nrng.nextInt(20)<br \/>\nrng.nextInt(20)<\/code><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Your task this week is to implement a program to represent decks and hands of playing cards. Download the\u00a0cards.zip file and uncompress it. It contains an incomplete BlueJ project called cards. Open the project and inspect the classes: Card \u2013 this represents a single playing card. Deck \u2013 this represents a deck of cards. The [&hellip;]<\/p>\n","protected":false},"author":328,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[236],"tags":[],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts\/141","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\/328"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":4,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":145,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts\/141\/revisions\/145"}],"wp:attachment":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}