zoukankan      html  css  js  c++  java
  • 西游

    2.按要求编写Java应用程序:

    (1)编写西游记人物类(XiYouJiRenWu)

    其中属性有:身高(height),名字(name),武器(weapon)

    方法有:显示名字(printName),显示武器(printWeapon)

    (2)在主类的main方法中创建二个对象:zhuBaJie,sunWuKong。并分别为他

    们的两个属性(name,weapon)赋值,最后分别调用printName, printWeapon方法

    显示二个对象的属性值。


    package com.mianxiangduixiang; public class XiYouJiRenWu { double shenGao; String weapon; String name; XiYouJiRenWu(double sg,String w,String n) { shenGao=sg; name=n; weapon=w; } String name() { return name; } String weapon() { return weapon; } }

      

    package com.mianxiangduixiang;
    
    public class XiYouJiRenWu1 {
    
        public static void main(String[] args) 
        {
            XiYouJiRenWu WuKong =new XiYouJiRenWu(180.0, "金箍棒", "悟空");
            {
                System.out.println(WuKong.name+WuKong.shenGao+WuKong.weapon);
            }
            XiYouJiRenWu BaJie =new XiYouJiRenWu(180.0, "钉耙", "八戒");    
            {
                System.out.println(BaJie.name+BaJie.shenGao+BaJie.weapon());
            }
            
        }
    
    }

  • 相关阅读:
    Python-读取文件内容
    torch_03_二分类
    torch_02_多项式回归
    pytorch_01_基础_一维线性回归
    LC-KSVD 代码解读
    标签一致项(LC-KSVD)-全文解读
    PCA:主成分分析
    牛客刷题-大佬链接
    调试MATLAB代码
    scroll offset & client总结
  • 原文地址:https://www.cnblogs.com/Levi1995/p/5884008.html
Copyright © 2011-2022 走看看