/* 这些是我的课程,我在编译我的课程时遇到问题?我不确定出了什么问题*/
这将是我的枚举类,我将在我的案例陈述中使用它
public enum Quarter
{
First,
Second,
Third,
Forth
}
这些是我的类字段。我不太确定我在网上看到的扫描仪字段,但它编译不正确。这是将扫描仪类型声明为字段的正确方法吗?
public class Quarterly
{
private final const ROW = 6;
private final const COL = 4;
private Scanner _scanner;
public Quarterly(Scanner scanner) // This Constructor does not compile either? What am I doing Wrong???
{
this._scanner = scanner;
}
这将是一种只接收用户输入的方法。但是我在这个案例陈述中遇到了麻烦
private string GetMessage(Quarter quarter, int departmentNumber)
{
switch(quarter)
{
case Quarter.first:
return "Enter The First Quarterly Sales For Department [ " + departmentNumber+" ]. . . . . $ ";
case Quarter.second:
return "Enter a The Second Quarterly Sales For Department [ " + departmentNumber+" ]. . . . . $ ";
case Quarter.third:
return "Enter a The Third Quarterly Sales For Department [ " + departmentNumber+" ]. . . . . $ ";
case Quarter.forth:
return "Enter a The Forth Quarterly Sales For Department [ " + departmentNumber+" ]. . . . . $ ";
}
}
这将是一个数组,用于获取我的部门总数并总结它们
public double GetTotalForDepartments(Quarter quarter)
{
double [][] sales = new double [ROW][COL];
int num = 1;
double total = 0;
for (int row = 0; row < ROW ; row++)
{
// This for statement is taking one column from the array in order to fill with input
for (int col = 0; col < COL; col++)
{
// This will receive sale numbers from the six departments
System.out.print(message + "[" + num + " ]. . . . . $ ");
sales[row][col] = _scanner.nextDouble();
num++;
// This for statement will sum each department's input
for (int i = 0; i < sales.length; i++);
{
total += sales[row][col];
}
}
}
return total;
}
/ This will be my main program.
{
double test1;
double test2;
double test3;
double test4;
Scanner keyboard = new Scanner(System.in);
Quarterly helper = new Quarterly(keyboard);
test1 = helper.GetTotalForDepartments(Quarter.First);
System.out.println(" Test 1 = " + test1);
test2 = helper.GetTotalForDepartments(Quarter.Second);
System.out.println(" Test 2 = " + test2);
test3 = helper.GetTotalForDepartments(Quarter.Third);
System.out.println(" Test 3 = " + test3);
test4 = helper.GetTotalForDepartments(Quarter.Fourth);
System.out.println(" Test 4 = " + test4 " /n ");
}