学习练习 java编写西游记人物类

 1 package com.hanqi;
 2 
 3 public class XiYouJiRenWu {
 4 
 5     double height;
 6     
 7     String weapon;
 8     
 9     String name;
10     
11     void prinetname()
12     {
13         System.out.println(name);
14     }
15     
16     void prinetweapon()
17     {
18         System.out.println("武器" + weapon);
19     }
20     
21     public static void main (String[] args)
22     {
23         XiYouJiRenWu sw = new XiYouJiRenWu();
24         sw.name=("孙悟空");
25         sw.weapon=("如意金箍棒");
26         System.out.println(sw.name+"使用的是"+sw.weapon);
27         sw.name=("猪八戒");
28         sw.weapon=("九齿钉耙");
29         System.out.println(sw.name+"使用的是"+sw.weapon);
30         
31     }
32     
33 }

原文地址:https://www.cnblogs.com/zhoudi/p/5501968.html