在线编译器最多只能运行一堂课

时间:2019-10-14 17:12:06

标签: java

我正在使用在线编译器“ onlinegdp”运行Java,并且无法在编程中使用多个文件。完全相同的代码可以在Eclipse上运行,所以我不确定问题出在哪里。

我对Java知之甚少,无法尝试Object myObject = newObject(); 。所以任何事情都会有所帮助。

这是我的工人班上的东西

public class Worker
{
  private int hours;
  private double rate;
public Worker ()
{
  hours = 999;
  rate = 999;
}
public Worker (int nHours, double nRate)
{
  hours = nHours;
  rate = nRate;
}
public int getHours ()
{
  return hours;
}
public void setHours (int nHours)
{
  hours = nHours;
}
public double getRate ()
{
  return rate;
}
public void setRate (double nRate)
{
  rate = nRate;
}
public double paycheck ()
{
  return rate * hours;
}
public void raiseRate (double raiseRate)
{
  rate = raiseRate + rate;
}

}

这是主要课程

public class Main
{

public static void main (String[]args)
{
  Worker bob = new Worker ();
  System.out.println (bob.getHours ());
  System.out.println (bob.getRate ());
  bob.setHours (9);
  bob.setRate (7.9);
  System.out.println (bob.getHours ());
  System.out.println (bob.getRate ());
  System.out.println (bob.payCheck ());
  System.out.println (bob.raiseRate ());
}
}

我收到此错误
Main.java:14:错误:找不到符号
Worker bob =新的Worker();
^
符号:工人阶级
位置:Main类

1 个答案:

答案 0 :(得分:-1)