{"id":687,"date":"2022-10-05T23:17:00","date_gmt":"2022-10-05T15:17:00","guid":{"rendered":"https:\/\/qaqaq.top\/?p=687"},"modified":"2022-12-19T20:04:32","modified_gmt":"2022-12-19T12:04:32","slug":"%e9%9d%a2%e5%90%91%e5%af%b9%e8%b1%a1%e4%b8%ad-%e7%bb%a7%e6%89%bf%e6%80%a7%e7%bb%83%e4%b9%a01%ef%bc%9a%e5%9f%ba%e6%9c%ac%e6%93%8d%e4%bd%9c-2","status":"publish","type":"post","link":"https:\/\/qaqaq.top\/?p=687","title":{"rendered":"\u9762\u5411\u5bf9\u8c61(\u4e2d)-\u7ee7\u627f\u6027\u7ec3\u4e601\uff1a\u57fa\u672c\u64cd\u4f5c"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>package top.qaqaq.java.P267;\n\n\/*\n\t\u5b9a\u4e49\u4e00\u4e2aManKind\u7c7b\uff0c\u5305\u62ec\n\t\u6210\u5458\u53d8\u91cfint sex\u548cint salary\uff1b\n\t\u65b9\u6cd5void manOrWoman()\uff1a\u6839\u636esex\u7684\u503c\u663e\u793a\u201cman\u201d(sex==1)\u6216\u8005\u201cwoman\u201d(sex==0)\uff1b\n\t\u65b9\u6cd5void employeed()\uff1a\u6839\u636esalary\u7684\u503c\u663e\u793a\u201cno job\u201d(salary==0)\u6216\u8005\u201c job\u201d(salary!=0)\u3002\n * \n * \n *\/\npublic class ManKind {\n\n\tprivate int sex;\/\/ \u6027\u522b\n\tprivate int salary;\/\/ \u85aa\u8d44\n\n\tpublic ManKind() {\n\t}\n\n\tpublic ManKind(int sex, int salary) {\n\t\tthis.sex = sex;\n\t\tthis.salary = salary;\n\t}\n\n\tpublic void manOrWoman() {\n\t\tif (sex == 1) {\n\t\t\tSystem.out.println(\"man\");\n\t\t} else if (sex == 0) {\n\t\t\tSystem.out.println(\"woman\");\n\t\t}\n\t}\n\n\tpublic void employeed() {\n\/\/\t\tif(salary == 0) {\n\/\/\t\t\tSystem.out.println(\"no job\");\n\/\/\t\t}else {\n\/\/\t\t\tSystem.out.println(\"job\");\n\/\/\t\t}\n\t\t\/\/ \u6216\n\t\tString jobInfo = (salary == 0) ? \"no job\" : \"job\";\n\t\tSystem.out.println(jobInfo);\n\t}\n\n\tpublic int getSex() {\n\t\treturn sex;\n\t}\n\n\tpublic void setSex(int sex) {\n\t\tthis.sex = sex;\n\t}\n\n\tpublic int getSalary() {\n\t\treturn salary;\n\t}\n\n\tpublic void setSalary(int salary) {\n\t\tthis.salary = salary;\n\t}\n\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package top.qaqaq.java.P267;\n\n\/*\n\t\u5b9a\u4e49\u7c7bKids\u7ee7\u627fManKind\uff0c\u5e76\u5305\u62ec\n\t\u6210\u5458\u53d8\u91cfint yearsOld\uff1b\n\t\u65b9\u6cd5printAge()\u6253\u5370yearsOld\u7684\u503c\u3002\n * \n * \n *\/\npublic class Kids extends ManKind {\n\n\tprivate int yearsOld;\n\n\tpublic Kids() {\n\t}\n\n\tpublic Kids(int yearsOld) {\n\t\tthis.yearsOld = yearsOld;\n\t}\n\n\tpublic void printAge() {\n\t\tSystem.out.println(\"I am \" + yearsOld + \" years old.\");\n\t}\n\n\tpublic int getYearsOld() {\n\t\treturn yearsOld;\n\t}\n\n\tpublic void setYearsOld(int yearsOld) {\n\t\tthis.yearsOld = yearsOld;\n\t}\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package top.qaqaq.java.P267;\n\/*\n * \u5b9a\u4e49\u7c7bKidsTest\uff0c\u5728\u7c7b\u7684main\u65b9\u6cd5\u4e2d\u5b9e\u4f8b\u5316Kids\u7684\u5bf9\u8c61someKid\uff0c\u7528\u8be5\u5bf9\u8c61\u8bbf\u95ee\u5176\u7236\u7c7b\u7684\u6210\u5458\u53d8\u91cf\u53ca\u65b9\u6cd5\u3002\n * \n * \n *\/\npublic class KidsTest {\n\tpublic static void main(String&#91;] args) {\n\t\t\n\t\tKids someKid = new Kids(12);\n\t\t\n\t\tsomeKid.printAge();\n\t\t\n\t\tsomeKid.setSalary(0);\n\t\tsomeKid.setSex(1);\n\t\t\n\t\tsomeKid.employeed();\n\t\tsomeKid.manOrWoman();\n\n\t}\n\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package top.qaqaq.java.P267;\n\npublic class Person {\n\t\n\tString name;\n\tchar sex;\n\tint age;\n\t\n\tpublic Person() {\n\t\t\n\t}\n\tpublic Person(String name,char sex,int age) {\n\t\tthis.name = name;\n\t\tthis.sex = sex;\n\t\tthis.age = age;\n\t}\n\t\n\tpublic String toString() {\n\t\treturn name + sex + age;\n\t}\n\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package top.qaqaq.java.P267;\n\npublic class Student extends Person {\n\n\tlong number;\n\tint math;\n\tint english;\n\tint computer;\n\t\n\tpublic Student() {\n\t\t\n\t}\n\t\n\tpublic Student(String n, char s, int a, long k, int m, int e, int c) {\n\t\tthis.name = n;\n\t\tthis.sex = s;\n\t\tthis.age = a;\n\t\tthis.number = k;\n\t\tthis.math = m;\n\t\tthis.english = e;\n\t\tthis.computer = c;\n\t}\n\t\n\tpublic double aver() {\n\t\treturn math + english + computer;\n\t}\n\t\n\tpublic int max() {\n\t\tint max1 = (math &gt; english)? math : english;\n\t\tint max2 = (max1 &gt; computer)? max1 : computer;\n\t\t\n\t\treturn max2;\n\t}\n\t\n\tpublic int min() {\n\t\tint min1 = (math &lt; english)? math : english;\n\t\tint min2 = (min1 &lt; computer)? min1 : computer;\n\t\t\n\t\treturn min2;\n\t\t\n\t}\n\t\n\tpublic String toString() {\n\t\treturn name +sex + age + number + math + english + computer;\n\t}\n\t\n\t\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[46],"class_list":["post-687","post","type-post","status-publish","format-standard","hentry","category-java-code","tag-java"],"_links":{"self":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/687"}],"collection":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=687"}],"version-history":[{"count":2,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/687\/revisions"}],"predecessor-version":[{"id":2653,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/687\/revisions\/2653"}],"wp:attachment":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}