LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 591|回复: 1

新手写的代码,出错,请帮忙看下

[复制链接]
发表于 2004-12-27 02:12:37 | 显示全部楼层 |阅读模式
下面的代码是我今天写的,写的有点乱气八朝。
不多不知道为什么
javac AdminHour.java 可以成功
但是运行就成功不的了
java AdminHour.class 就出现了错误

Exception in thread "main" java.lang.NoClassDefFoundError: AdminHour/class



代码:

import javax.swing.*;

public class AdminHour
{
   public static void main(String[] args)
   {
      Emplogee[] staff = new Emplogee[3];
      
   String   input = JOptionPane.showInputDialog
      ("how much money for A take");
   int k = Integer.parseInt(input);


   input = JOptionPane.showInputDialog
      ("how much money for B take");
   int k1 = Integer.parseInt(input);


   input = JOptionPane.showInputDialog
      ("how much money for C take");
   int k2 = Integer.parseInt(input);


   input = JOptionPane.showInputDialog
      ("How much add ");
   double add = Integer.parseInt(input);


    input = JOptionPane.showInputDialog
      ("how much money for zg take");
   int zgmoney = Integer.parseInt(input);


    input = JOptionPane.showInputDialog
      ("how much money for zg add");
   int zgadd = Integer.parseInt(input);



   staff[0] = new Emplogee("A",k );
   staff[1] = new Emplogee("B",k1);
   staff[2] = new Emplogee("C",k2);
    Manager boss = new Manager("D",zgmoney);
      boss.setBonus(zgadd);
    staff[3] = boss;

    for(int i = 0;i < staff.length; i++)
      staff.getAdd(add);

   for(int i = 0;i < staff.length; i++)
      {Emplogee e = staff;
      System.out.println("name=" + e.getName() + "\nOmoney=" + e.getOmoney() + "\nNmoney=" + e.getNmoney());
      }
   }
}
class Emplogee
{
   public Emplogee (String n ,double s)
   {   name = n;
      money = s;
   }
   public String getName()
   {
      return name;
   }
   public double getOmoney()
   {
      return money;
   }
   public double getNmoney()
   {
        return Hadd;
   }
   public void  getAdd(double byPercent)
   {
      double raise = money * byPercent / 100;
      Hadd = raise + money;
   }
   private String name;
   private double money;
   private double Hadd;
   
}


class Manager extends Emplogee
{
   /**
      @param n the employee's name
      @param s the onmeny
   */
   public Manager(String n, double s)
   {
      super(n, s);
      bonus = 0;
   }

   public double getSalary()
   {
      double baseSalary = super.getOmoney();
      return baseSalary + bonus;
   }

   public void setBonus(double b)
   {
      bonus = b;
   }

   private double bonus;
}
 楼主| 发表于 2004-12-27 02:50:35 | 显示全部楼层
不好意思~~我在论坛的精华中找到了~~呵呵
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表