{"id":875,"date":"2013-09-12T17:19:28","date_gmt":"2013-09-12T10:19:28","guid":{"rendered":"http:\/\/kusumotolab.com\/?p=875"},"modified":"2013-09-12T17:19:28","modified_gmt":"2013-09-12T10:19:28","slug":"java-lab-polymorphism","status":"publish","type":"post","link":"https:\/\/oldblog.kusumotolab.com\/?p=875","title":{"rendered":"Java Lab Polymorphism"},"content":{"rendered":"<pre lang=\"java\">\r\npackage artistdemo;\r\n\r\nclass Shape {\r\n    void drow() {\r\n        System.out.println(\"Drawing a Shape.\");\r\n    }\r\n}\r\n\r\nclass Rectangle extends Shape {\r\n    int width,height;\r\n    Rectangle(int w,int h) {\r\n        width = w;\r\n        height = h;\r\n    }\r\n    void drow() {\r\n        System.out.println(\"Draw a rectangle...width=\"+width+\"height=\"+height);\r\n    }\r\n}\r\n\r\nclass Triangle extends Shape {\r\n    int base,height;\r\n    Triangle(int b,int h){\r\n        base = b;\r\n        height = h;\r\n    }\r\n     void drow() {\r\n        System.out.println(\"Draw a Triangle...base=\"+base+\"height=\"+height);\r\n    }\r\n}\r\n\r\nclass Artist {\r\n    public void drawShape(Shape s){\r\n        s.drow();\r\n    }\r\n    \r\n}\r\n\r\npublic class ArtistDemo {\r\n\r\n    public static void main(String[] args) {\r\n        Shape a = new Shape();\r\n        Rectangle b = new Rectangle(3,4);\r\n        Triangle c = new Triangle(6,7);\r\n        Artist x = new Artist();\r\n        x.drawShape(a);\r\n        x.drawShape(b);\r\n        x.drawShape(c);\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>package artistdemo; class Shape { void drow() { System.out.println(&#8220;Drawing a Shape.&#8221;); } } class Rectangle extends Shape { int width,height; Rectangle(int w,int h) { width = w; height = h; } void drow() { System.out.println(&#8220;Draw a rectangle&#8230;width=&#8221;+width+&#8221;height=&#8221;+height); } } class Triangle extends Shape { int base,height; Triangle(int b,int h){ base = b; height = h; [&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":[54,59],"tags":[],"class_list":["post-875","post","type-post","status-publish","format-standard","hentry","category-homework","category-java"],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3OMEb-e7","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/875","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=875"}],"version-history":[{"count":2,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/875\/revisions"}],"predecessor-version":[{"id":877,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/875\/revisions\/877"}],"wp:attachment":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}