{"id":914,"date":"2013-11-07T15:42:30","date_gmt":"2013-11-07T08:42:30","guid":{"rendered":"http:\/\/kusumotolab.com\/?p=914"},"modified":"2013-11-07T15:42:30","modified_gmt":"2013-11-07T08:42:30","slug":"aoop-lab-day-2","status":"publish","type":"post","link":"https:\/\/oldblog.kusumotolab.com\/?p=914","title":{"rendered":"AOOP lab day 2"},"content":{"rendered":"<h2>Package flower.lib<\/h2>\n<p>flower.java<\/p>\n<pre lang=\"java\">\r\npackage flower.lib;\r\n\r\npublic class Flower {\r\n\t\r\n\tpublic Flower(int p) {\r\n\t\tthis.price = p;\r\n\t}\r\n\t\r\n\tpublic Flower() {\r\n\t\tthis.price = 0;\r\n\t}\r\n\t\r\n\t\r\n\tprotected int price;\r\n\t\r\n\tpublic void printDetail() {\r\n\t\tSystem.out.println(\"Flower\");\r\n\t}\r\n\t\r\n\tpublic int getPrice() {\r\n\t\treturn price;\r\n\t}\r\n}\r\n<\/pre>\n<p>orchid.java<\/p>\n<pre lang=\"java\">\r\npackage flower.lib;\r\n\r\npublic class Orchid extends Flower{\r\n\t\r\n\tpublic Orchid(int p) {\r\n\t\tthis.price = p;\r\n\t}\r\n\t\r\n\tpublic Orchid() {\r\n\t\tthis.price = 6;\r\n\t}\r\n\t\r\n\tpublic void printDetail() {\r\n\t\tSystem.out.println(\"Orchid\");\r\n\t}\r\n\t\r\n\tpublic int getPrice() {\r\n\t\treturn price;\r\n\t}\r\n}\r\n\r\n<\/pre>\n<p>sunflower.java<\/p>\n<pre lang=\"java\">\r\npackage flower.lib;\r\n\r\npublic class Sunflower extends Flower{\r\n\tpublic Sunflower(int p) {\r\n\t\tthis.price = p;\r\n\t}\r\n\t\r\n\tpublic Sunflower() {\r\n\t\tthis.price = 1;\r\n\t}\r\n\t\r\n\tpublic void printDetail() {\r\n\t\tSystem.out.println(\"Sunflower\");\r\n\t}\r\n\t\r\n\tpublic int getPrice() {\r\n\t\treturn price;\r\n\t}\r\n}\r\n<\/pre>\n<p>tulip.java<\/p>\n<pre lang=\"java\">\r\npackage flower.lib;\r\n\r\npublic class Tulip extends Flower{\r\n\tpublic Tulip(int p) {\r\n\t\tthis.price = p;\r\n\t}\r\n\t\r\n\tpublic Tulip() {\r\n\t\tthis.price = 5;\r\n\t}\r\n\t\r\n\tpublic void printDetail() {\r\n\t\tSystem.out.println(\"Tulip\");\r\n\t}\r\n\t\r\n\tpublic int getPrice() {\r\n\t\treturn price;\r\n\t}\r\n}\r\n\r\n<\/pre>\n<h2>Package flower.program<\/h2>\n<p>flower_store.java<\/p>\n<pre lang=\"java\">\r\npackage flower.program;\r\nimport java.io.IOException;\r\nimport java.util.Scanner;\r\n\r\nimport flower.lib.*;\r\n\r\npublic class Flower_store {\r\n\r\n\tpublic static void main(String[] args) throws IOException {\r\n\t\tScanner s = new Scanner(System.in);\r\n\t\tint count = 0;\r\n\t\tFlower[] bouquest = new Flower[1000];\r\n\t\t\r\n\t\tSystem.out.println(\"Welcome to flower program!!\");\r\n\t\twhile(true) {\r\n\t\tSystem.out.println(\"What type of flower would you like to add in to your bouquet?\");\r\n\t\tSystem.out.println(\"[s]unflower, [t]ulip, [o]rchid, [q]uit, [v]iew, [r]eset current bouquet\");\r\n\t\tString input = s.next();\r\n\t\t\/\/System.out.println(input);\r\n\t\t\r\n\t\tif (input.equalsIgnoreCase(\"s\")) {\r\n\t\t\tbouquest[count] = new Sunflower();\r\n\t\t\tcount++;\r\n\t\t\t\r\n\t\t\t\/\/Sunflower f1 = new Sunflower(1);\r\n\t\t\t\/\/count = (count + f1.getPrice());\r\n\t\t}else if (input.equalsIgnoreCase(\"t\")){\r\n\t\t\tbouquest[count] = new Tulip();\r\n\t\t\tcount++;\r\n\t\t\t\r\n\t\t\t\/\/Tulip f2 = new Tulip(5);\r\n\t\t\t\/\/count = (count + f2.getPrice());\r\n\t\t\t\r\n\t\t}else if (input.equalsIgnoreCase(\"o\")){\r\n\t\t\tbouquest[count] = new Orchid();\r\n\t\t\tcount++;\r\n\t\t\t\r\n\t\t\t\/\/Orchid f3 = new Orchid(6);\r\n\t\t\t\/\/count = (count + f3.getPrice());\r\n\t\t\t\r\n\t\t}else if (input.equalsIgnoreCase(\"v\")) {\r\n\t\t\tSystem.out.println(\"----- Your Bouquet -----\");\r\n\t\t\tint cost=0;\r\n\t\t\tfor (int i=0; i<count; i++) {\r\n\t\t\t\tSystem.out.print((i+1)+\" \");\r\n\t\t\t\tbouquest[i].printDetail();\r\n\t\t\t\tcost = cost + bouquest[i].getPrice();\r\n\t\t\t}\r\n\t\t\tSystem.out.println(\"------------------------\");\r\n\t\t\tSystem.out.println(\"Total cost is $\"+cost);\r\n\t\t\t\/\/System.out.println(\"Total cost is $\"+total);\r\n\t\t\tSystem.out.println(\"------------------------\");\r\n\t\t}else if (input.equalsIgnoreCase(\"r\")) {\r\n\t\t\tfor (int i=0; i<count; i++) {\r\n\t\t\t\tbouquest[i] = null;\r\n\t\t\t}\r\n\t\t\tSystem.out.println(\"Reset current bouquet Complete.\");\r\n\t\t\tcount = 0;\r\n\t\t}\r\n\t\t\r\n\t\tif (input.equalsIgnoreCase(\"q\")) {\r\n\t\t\tSystem.out.println(\"Bye Bye!\");\r\n\t\t\tSystem.exit(0);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Package flower.lib flower.java package flower.lib; public class Flower { public Flower(int p) { this.price = p; } public Flower() { this.price = 0; } protected int price; public void printDetail() { System.out.println(&#8220;Flower&#8221;); } public int getPrice() { return price; } } orchid.java package flower.lib; public class Orchid extends Flower{ public Orchid(int p) { this.price = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[59],"tags":[],"class_list":["post-914","post","type-post","status-publish","format-standard","hentry","category-java"],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3OMEb-eK","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/914","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=914"}],"version-history":[{"count":2,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/914\/revisions"}],"predecessor-version":[{"id":916,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/914\/revisions\/916"}],"wp:attachment":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}