| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 537 人关注过本帖
标题:求助一下,谢谢
只看楼主 加入收藏
anhuizxw
Rank: 1
等 级:新手上路
帖 子:17
专家分:6
注 册:2009-7-12
结帖率:83.33%
收藏
已结贴  问题点数:20 回复次数:3 
求助一下,谢谢
class Employee
{
    private String name;
   
    private double salary;
   
    private Date hireDay;
   
    public Employee(String n,double s,int year,int month,int day)
   
    {
        name=n;
        
        salary=s;
        
        GregorianCalendar calendar=new GregorianCalendar(year,month-1,day);
        
        hireDay=calendar.getTime();
        
    }
   
    public String getName()
   
    {
        
        return name;
        
    }
   
    public double getSalary()
   
    {
        
        return salary;
        
    }
   
    public Date getHireDay()
   
    {
        
        return hireDay;
        
    }
   
    public void raiseSalary(double byPercent)
   
    {
        
        double raise=salary*byPercent/100;
        
        salary+=raise;
        
    }
   
}

public class EmployeeTest

{
   
    public static void main(String[] args)
   
    {
        
        Employee[] staff=new Employee[3];
        
        staff[0]=new Employee("Carl Cracker",75000,1987,12,15);
        
        staff[1]=new Employee("Harry Hacker",50000,1989,10,1);
        
        staff[2]=new Employee("Tony Tester",40000,1990,3,15);
        
        for(Employee e:staff)
        
        e.raiseSalary(5);
        
        for(Employee e:staff)
        
        System.out.println("Name="+e.getName()+",Salary="+e.getSalary()+",HireDay="+e.getHireDay());
        
    }
   
}
不知道怎么错了,请帮忙指点下,谢谢了!
2009-11-23 20:47
lampeter123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:54
帖 子:2508
专家分:6424
注 册:2009-1-30
收藏
得分:20 
import java.util.Date;
import java.util.GregorianCalendar;

class Employee
{
    private String name;
   
    private double salary;
   
    private Date hireDay;
   
    public Employee(String n,double s,int year,int month,int day)
   
    {
        name=n;
        
        salary=s;
        
        GregorianCalendar calendar=new GregorianCalendar(year,month-1,day);
        
        hireDay=calendar.getTime();
        
    }
   
    public String getName()
   
    {
        
        return name;
        
    }
   
    public double getSalary()
   
    {
        
        return salary;
        
    }
   
    public Date getHireDay()
   
    {
        
        return hireDay;
        
    }
   
    public void raiseSalary(double byPercent)
   
    {
        
        double raise=salary*byPercent/100;
        
        salary+=raise;
        
    }
   
}

public class EmployeeTest

{
   
    public static void main(String[] args)
   
    {
        
        Employee[] staff=new Employee[3];
        
        staff[0]=new Employee("Carl Cracker",75000,1987,12,15);
        
        staff[1]=new Employee("Harry Hacker",50000,1989,10,1);
        
        staff[2]=new Employee("Tony Tester",40000,1990,3,15);
        
        for(Employee e:staff)
        
        e.raiseSalary(5);
        
        for(Employee e:staff)
        
        System.out.println("Name="+e.getName()+",Salary="+e.getSalary()+",HireDay="+e.getHireDay());
        
    }
   
}
//~运行结果
Name=Carl Cracker,Salary=78750.0,HireDay=Tue Dec 15 00:00:00 CST 1987
Name=Harry Hacker,Salary=52500.0,HireDay=Sun Oct 01 00:00:00 CST 1989
Name=Tony Tester,Salary=42000.0,HireDay=Thu Mar 15 00:00:00 CST 1990

你的优秀和我的人生无关!!!!
    
    我要过的,是属于我自己的生活~~~
2009-11-23 20:59
anhuizxw
Rank: 1
等 级:新手上路
帖 子:17
专家分:6
注 册:2009-7-12
收藏
得分:0 
回复 2楼 lampeter123
谢谢。明白了
2009-11-23 21:15
haizeng
Rank: 2
来 自:xdpsj.com
等 级:等待验证会员
帖 子:61
专家分:36
注 册:2009-11-30
收藏
得分:0 
  都是细节问题 注意就可以啦

[url=http://www./]石料生产线[/url]
[url=http://www.]破碎机[/url]
2009-11-30 09:55
快速回复:求助一下,谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023108 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved