正在回答 回答被采纳积分+1
2回答
qq_孤独沉寂_0
2017-07-05 22:52:48
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | package com.imcco.zuoye; public class Bumeilei { private String mz; private String zw; public Bumeilei(){ } public Bumeilei(String zw){ this .setZw(zw); } public String getZw() { return zw; } public void setZw(String zw) { this .zw = zw; } public String iof(){ String sr; sr= "职务:" + this .getZw(); return sr; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | package com.imcco.zuoye; public class Ygl { private String xm; private String gh; private int nl; private String xb; private Ygl[]myset; private int YglNume; public Ygl(){ } public Ygl(String xm,String gh, int nl,String xb){ this .setXm(xm); this .setGh(gh); this .setNl(nl); this .setXb(xb); } //带参的属性赋值 public Ygl(String xm,String gh, int nl,String xb,Ygl[]myset){ this .setXm(xm); this .setGh(gh); this .setNl(nl); this .setXb(xb); this .setMyset(myset); } public String getXm() { return xm; } public void setXm(String xm) { this .xm = xm; } public String getGh() { return gh; } public void setGh(String gh) { this .gh = gh; } public int getNl() { return nl; } public void setNl( int nl) { if (nl>= 18 &&nl<= 65 ) this .nl = nl; else this .nl= 18 ; } public String getXb() { return xb; } public void setXb(String xb) { if (xb.equals( "女" )) this .xb = xb; else this .xb= "男" ; } /** * 获取员工,如果保存员工信息数组未被初始化,则,先初始化的长度为200 * @return保存员工信息的数组 */ public Ygl[] getMyset() { if ( this .myset== null ) this .myset= new Ygl[ 200 ]; return myset; } public void setMyset(Ygl[] myset) { this .myset = myset; } public String inf(String zw){ String sr; sr= "姓名:" + this .getXm()+ "\n工号:" + this .getGh()+ "\n性别:" + this .getXb()+ "\n年龄:" + this .getNl()+ "\n职务:" +zw; return sr; } public void addYgl(Ygl stu){ for ( int i= 0 ;i< this .getMyset().length;i++){ if ( this .getMyset()[i]== null ){ this .getMyset()[i]=stu; this .YglNume=i+ 1 ; break ; } } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | package com.imcco.zuoye; public class Tst { public static void main(String[] args) { Bumeilei s= new Bumeilei(); Ygl a1= new Ygl( "张铭" , "S001" , 29 , "男" ); System.out.println(a1.inf( "人事部经理" )); System.out.println( "==================" ); Ygl a2= new Ygl( "李艾爱" , "S002" , 21 , "女" ); System.out.println(a2.inf( "人事部助理" )); System.out.println( "==================" ); Ygl a3= new Ygl( "孙超" , "S004" , 29 , "男" ); System.out.println(a3.inf( "人事部职员" )); System.out.println( "==================" ); Ygl a4= new Ygl( "张梅梅" , "S005" , 26 , "女" ); System.out.println(a4.inf( "市场部职员" )); System.out.println( "===================" ); Ygl a5= new Ygl( "蓝迪" , "S006" , 37 , "男" ); System.out.println(a5.inf( "市场部经理" )); System.out.println( "===================" ); Ygl a6= new Ygl( "米莉" , "S007" , 24 , "女" ); System.out.println(a6.inf( "市场部职员" )); System.out.println( "====================" ); a1.addYgl(a1); a2.addYgl(a2); a3.addYgl(a3); a4.addYgl(a4); a5.addYgl(a5); a6.addYgl(a6); System.out.println(s.iof()+ "部门有" +s.iof()); } } |
为啥统计不了啊???求解
好帮手慕珊
2017-07-01 12:31:38
点击作业需求下方的评分标准是什么,可以看到每个类的具体描述。
比如:部门类,可以有部门编号、名称、员工数组、员工数量四个属性,也就是这四个变量,及相关的get和set方法,除此以外还包括一个添加员工的方法,在添加员工的同时进行员工数量的统计。
职务类包括职务的编号和名称,及相关的get和set方法
员工类包括列出的六个属性和相关的get和set方法,并且根据需求在相关set方法中对年龄和性别进行设置,还包括一个返回员工信息的方法。
最后的测试类中就是定义6个员工对象,2个部门对象,3个职务对象,然后将员工添加到部门中,并打印输出员工信息和每个部门的员工数量。
这个作业题和老师讲的例题十分类似,建议再看看视频。祝学习愉快!
Android零基础入门2018版
- 参与学习 人
- 提交作业 5461 份
- 解答问题 7235 个
此次推出的专题为Android攻城狮培养计划的第一部分语法与界面基础篇,将带大家从0开始学习Android开发。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧