我正在编写我的第一个 Java 程序,该程序将用于实际目的,但我被困住了——得到一个不正确的输出。
这是我正在尝试计算的问题:我工作的制造工厂一年 363 天(圣诞节前夕和圣诞节期间)每天 24 小时 7 天运行,四天倒班。每个工作人员连续工作 4 个 12 小时的白天或夜晚,然后休息 4 天。有四个工作人员,每个工作四天,然后休息四天,然后工作四个晚上,然后休息四个晚上。A Crew 和 B Crew 彼此相反旋转,C Crew 和 D Crew 彼此相反旋转。
当 A 组和 B 组工作时,C 组和 D 组成员随时待命,以防 A 组或 B 组有人缺席。员工分为三类:高级操作员、初级操作员和复合操作员。每个工作人员有四名高级操作员、三名初级操作员和 2 名复合操作员。在四天轮换周期的前两天,三位高级接线员随叫随到,而第四位不随叫随到。在此期间不随叫随到的高级接线员轮换:每次其他人随叫随到时,一个不随叫随到。在过去的两天里,三位初级接线员随叫随到。
对于高级员工,上一个周期决定了他们是白班还是夜班待命:如果不工作的船员一直在白班工作,则高级操作员在前两天值班,反之亦然如果他们在上一个周期中一直在工作。对于初级操作员来说,他们即将开始的周期决定了他们在接下来的两天休息中是值班白班还是夜班。
复合工在第一天和第四天休息时随叫随到。他们是在白天还是晚上随叫随到,其决定方式与操作员相同。
我的目标是用 Java 编写一个程序,计算每天和每晚轮班值班的员工,并将结果输出到文本文件。我是一个业余爱好者,到目前为止只上过两门编程课,所以我确信我到目前为止所写的内容远没有它可能的效率那么高。我只是想弄清楚为什么输出不正确。我的怀疑是我要么错误地计算了一个变量,要么我完全错过了一块拼图。请注意,就该计划而言,一年的第一天是 1 月 3 日,因为第一天和第二天是上一年周期的一部分。
下面是我的代码。我删除了所有 getter 和 setter 以适应分配的长度。我感谢可以提供的任何和所有帮助。
import java.io.File;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;
public class OnCallAug812 {
Calendar cal1 = Calendar.getInstance();
private double cycleDay = ((cal1.get(Calendar.DAY_OF_YEAR) - 3)) % 16;
private double dayOfCycle = cycleDay % 4;
// number of days into current rotation ( 0 =4, 1=1, 2=2, 3=3)
private int cycleRotation = (int) (cycleDay / 4);
// number of current rotation (4 per cycle)
private int cycleOfYear = ((cal1.get(Calendar.DAY_OF_YEAR) - 3) / 16);
private int onCallCycle = cycleOfYear % 4;
// A crew operators: 4 Senior
private int a1S = 0;
private int a2S = 1;
private int a3S = 2;
private int a4S = 3;
// variables for A crew names
private String a1;
private String a2;
private String a3;
private String a4;
// A Crew Junior Operators represented by one variable b/c
// all are on call or not on call at same time
private int aJr;
// A crew junior operator names
private String aJr1;
private String aJr2;
private String aJr3;
// B crew operators: 4 Senior
private int b1S = 0;
private int b2S = 1;
private int b3S = 2;
private int b4S = 3;
// B crew operator names
private String b1;
private String b2;
private String b3;
private String b4;
// B Crew Junior Operators represented by one variable b/c
// all are on call or not on call at same time
private int bJr;
// B crew operator junior names
private String bJr1;
private String bJr2;
private String bJr3;
// C crew operators: 4 Senior
private int c1S = 0;
private int c2S = 1;
private int c3S = 2;
private int c4S = 3;
// C operator senior names
private String c1;
private String c2;
private String c3;
private String c4;
// C Crew Junior Operators represented by one variable b/c
// all are on call or not on call at same time
private int cJr;
// C crew junior operator names
private String cJr1;
private String cJr2;
private String cJr3;
// D crew operators: 4 Senior
private int d1S = 0;
private int d2S = 1;
private int d3S = 2;
private int d4S = 3;
// d crew senior names
private String d1;
private String d2;
private String d3;
private String d4;
// D Crew Junior Operators represented by one variable b/c
// all are on call or not on call at same time
private int dJr;
// D crew junior operator names
private String dJr1;
private String dJr2;
private String dJr3;
// Call status for each A Crew employee--set to 0,1, or 2
// 0 = on call day shift
// 1 = on call night shift
// 2 = off call
private int a1SCallStat = -1;
private int a2SCallStat = -1;
private int a3SCallStat = -1;
private int a4SCallStat = -1;
private int aJrCallStat = -1;
// Call status for each B Crew employee--set to 0,1, or 2
private int b1SCallStat = -1;
private int b2SCallStat = -1;
private int b3SCallStat = -1;
private int b4SCallStat = -1;
private int bJrCallStat = -1;
// Call status for each C Crew employee--set to 0,1, or 2
private int c1SCallStat = -1;
private int c2SCallStat = -1;
private int c3SCallStat = -1;
private int c4SCallStat = -1;
private int cJrCallStat = -1;
// Call status for each D Crew employee--set to 0,1, or 2
private int d1SCallStat = -1;
private int d2SCallStat = -1;
private int d3SCallStat = -1;
private int d4SCallStat = -1;
private int dJrCallStat = -1;
// Call status for each crew's pelletizer operators (both on or both off)
private int aP;
private int bP;
private int cP;
private int dP;
private String aP1;
private String aP2;
private String bP1;
private String bP2;
private String cP1;
private String cP2;
private String dP1;
private String dP2;
private int aPCallStat = -1;
private int bPCallStat = -1;
private int cPCallStat = -1;
private int dPCallStat = -1;
public int determineCall(double onCallCycle, int crewNumber) {
double aNumber = (crewNumber + onCallCycle) % 7;
if (aNumber <= 2) {
return 0;
} else if (aNumber >= 3 && aNumber < 6) {
return 1;
} else if (aNumber == 6) {
return 2;
} else
return -1;
}
public int determineCallJr(double onCallCycle, int crewNumber){
double aNumber = (crewNumber + onCallCycle) % 7;
if (aNumber <= 3) {
return 0;
} else if (aNumber >= 4 && aNumber <= 6) {
return 1;
} else
return -1;
}
public int determineCallP(double onCallCycle, int crewNumber){
double aNumber = (crewNumber + onCallCycle) % 7;
if (aNumber <= 3) {
return 0;
} else if (aNumber >= 4 && aNumber <= 6) {
return 1;
} else
return -1;
}
public void calcCall(OnCallAug812 aug1) {
// Senior employees on call checks
if ((aug1.cycleRotation == 0)
&& ((aug1.dayOfCycle == 1) || (aug1.dayOfCycle == 0))) {
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC1S()) == 0) {
aug1.setC1SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC1S()) == 1) {
aug1.setC1SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC1S()) == 2) {
aug1.setC1SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC2S()) == 0) {
aug1.setC2SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC2S()) == 1) {
aug1.setC2SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC2S()) == 2) {
aug1.setC2SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC3S()) == 0) {
aug1.setC3SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC3S()) == 1) {
aug1.setC3SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC3S()) == 2) {
aug1.setC3SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC4S()) == 0) {
aug1.setC4SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC4S()) == 1) {
aug1.setC4SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC4S()) == 2) {
aug1.setC4SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD1S()) == 0) {
aug1.setD1SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD1S()) == 1) {
aug1.setD1SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD1S()) == 2) {
aug1.setD1SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD2S()) == 0) {
aug1.setD2SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD2S()) == 1) {
aug1.setD2SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD2S()) == 2) {
aug1.setD2SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD3S()) == 0) {
aug1.setD3SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD3S()) == 1) {
aug1.setD3SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD3S()) == 2) {
aug1.setD3SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD4S()) == 0) {
aug1.setD4SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD4S()) == 1) {
aug1.setD4SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD4S()) == 2) {
aug1.setD4SCallStat(2);
}
}
if ((aug1.cycleRotation == 1)
&& ((aug1.dayOfCycle == 1) || (aug1.dayOfCycle == 0))) {
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA1S()) == 0) {
aug1.setA1SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA1S()) == 1) {
aug1.setA1SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA1S()) == 2) {
aug1.setA1SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA2S()) == 0) {
aug1.setA2SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA2S()) == 1) {
aug1.setA2SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA2S()) == 2) {
aug1.setA2SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA3S()) == 0) {
aug1.setA3SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA3S()) == 1) {
aug1.setA3SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA3S()) == 2) {
aug1.setA3SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA4S()) == 0) {
aug1.setA4SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA4S()) == 1) {
aug1.setA4SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA4S()) == 2) {
aug1.setA4SCallStat(2);
}
// b crew second rotation
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB1S()) == 0) {
aug1.setB1SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB1S()) == 1) {
aug1.setB1SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB1S()) == 2) {
aug1.setB1SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB2S()) == 0) {
aug1.setB2SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB2S()) == 1) {
aug1.setB2SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB2S()) == 2) {
aug1.setB2SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB3S()) == 0) {
aug1.setB3SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB3S()) == 1) {
aug1.setB3SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB3S()) == 2) {
aug1.setB3SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB4S()) == 0) {
aug1.setB4SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB4S()) == 1) {
aug1.setB4SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB4S()) == 2) {
aug1.setB4SCallStat(2);
}
}
if ((aug1.cycleRotation == 2)
&& ((aug1.dayOfCycle == 1) || (aug1.dayOfCycle == 0))) {
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC1S()) == 0) {
aug1.setC1SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC1S()) == 1) {
aug1.setC1SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC1S()) == 2) {
aug1.setC1SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC2S()) == 0) {
aug1.setC2SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC2S()) == 1) {
aug1.setC2SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC2S()) == 2) {
aug1.setC2SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC3S()) == 0) {
aug1.setC3SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC3S()) == 1) {
aug1.setC3SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC3S()) == 2) {
aug1.setC3SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC4S()) == 0) {
aug1.setC4SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC4S()) == 1) {
aug1.setC4SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getC4S()) == 2) {
aug1.setC4SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD1S()) == 0) {
aug1.setD1SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD1S()) == 1) {
aug1.setD1SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD1S()) == 2) {
aug1.setD1SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD2S()) == 0) {
aug1.setD2SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD2S()) == 1) {
aug1.setD2SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD2S()) == 2) {
aug1.setD2SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD3S()) == 0) {
aug1.setD3SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD3S()) == 1) {
aug1.setD3SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD3S()) == 2) {
aug1.setD3SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD4S()) == 0) {
aug1.setD4SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD4S()) == 1) {
aug1.setD4SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getD4S()) == 2) {
aug1.setD4SCallStat(2);
}
}
if ((aug1.cycleRotation == 3)
&& ((aug1.dayOfCycle == 1) || (aug1.dayOfCycle == 0))) {
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA1S()) == 0) {
aug1.setA1SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA1S()) == 1) {
aug1.setA1SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA1S()) == 2) {
aug1.setA1SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA2S()) == 0) {
aug1.setA2SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA2S()) == 1) {
aug1.setA2SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA2S()) == 2) {
aug1.setA2SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA3S()) == 0) {
aug1.setA3SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA3S()) == 1) {
aug1.setA3SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA3S()) == 2) {
aug1.setA3SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA4S()) == 0) {
aug1.setA4SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA4S()) == 1) {
aug1.setA4SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getA4S()) == 2) {
aug1.setA4SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB1S()) == 0) {
aug1.setB1SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB1S()) == 1) {
aug1.setB1SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB1S()) == 2) {
aug1.setB1SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB2S()) == 0) {
aug1.setB2SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB2S()) == 1) {
aug1.setB2SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB2S()) == 2) {
aug1.setB2SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB3S()) == 0) {
aug1.setB3SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB3S()) == 1) {
aug1.setB3SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB3S()) == 2) {
aug1.setB3SCallStat(2);
}
if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB4S()) == 0) {
aug1.setB4SCallStat(0);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB4S()) == 1) {
aug1.setB4SCallStat(1);
} else if (aug1.determineCall(aug1.getOnCallCycle(), aug1.getB4S()) == 2) {
aug1.setB4SCallStat(2);
}
}
// Junior Extruder Operators
if ((aug1.cycleRotation == 0)
&& ((aug1.dayOfCycle == 3) || (aug1.dayOfCycle == 2))) {
if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getcJr()) == 0) {
aug1.setcJrCallStat(0);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getcJr()) == 1) {
aug1.setcJrCallStat(1);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getcJr()) == 2) {
aug1.setcJrCallStat(2);
}
if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getdJr()) == 0) {
aug1.setDjrCallStat(1);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getdJr()) == 1) {
aug1.setDjrCallStat(0);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getdJr()) == 2) {
aug1.setDjrCallStat(2);
}
}
if ((aug1.cycleRotation == 1)
&& ((aug1.dayOfCycle == 3) || (aug1.dayOfCycle == 2))) {
if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getaJr()) == 0) {
aug1.setaJrCallStat(0);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getaJr()) == 1) {
aug1.setaJrCallStat(1);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getaJr()) == 2) {
aug1.setaJrCallStat(2);
}
if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getbJr()) == 0) {
aug1.setbJrCallStat(1);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getbJr()) == 1) {
aug1.setbJrCallStat(0);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getbJr()) == 2) {
aug1.setbJrCallStat(2);
}
}
if ((aug1.cycleRotation == 2)
&& ((aug1.dayOfCycle == 3) || (aug1.dayOfCycle == 2))) {
if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getcJr()) == 0) {
aug1.setcJrCallStat(0);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getcJr()) == 1) {
aug1.setcJrCallStat(1);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getcJr()) == 2) {
aug1.setcJrCallStat(2);
}
if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getdJr()) == 0) {
aug1.setDjrCallStat(1);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getdJr()) == 1) {
aug1.setDjrCallStat(0);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getdJr()) == 2) {
aug1.setDjrCallStat(2);
}
}
if ((aug1.cycleRotation == 3)
&& ((aug1.dayOfCycle == 3) || (aug1.dayOfCycle == 2))) {
if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getaJr()) == 0) {
aug1.setaJrCallStat(0);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getaJr()) == 1) {
aug1.setaJrCallStat(1);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getaJr()) == 2) {
aug1.setaJrCallStat(2);
}
if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getbJr()) == 0) {
aug1.setbJrCallStat(1);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getbJr()) == 1) {
aug1.setbJrCallStat(0);
} else if (aug1.determineCallJr(aug1.getOnCallCycle(), aug1.getbJr()) == 2) {
aug1.setbJrCallStat(2);
}
}
if ((aug1.cycleRotation == 0)
&& ((aug1.dayOfCycle == 3) || (aug1.dayOfCycle == 0))) {
if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getcP()) == 0) {
aug1.setcPCallStat(0);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getcP()) == 1) {
aug1.setcPCallStat(1);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getcP()) == 2) {
aug1.setcPCallStat(2);
}
if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getdP()) == 0) {
aug1.setdPCallStat(1);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getdP()) == 1) {
aug1.setdPCallStat(0);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getdP()) == 2) {
aug1.setdPCallStat(2);
}
}
if ((aug1.cycleRotation == 1)
&& ((aug1.dayOfCycle == 3) || (aug1.dayOfCycle == 0))) {
if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getaP()) == 0) {
aug1.setaPCallStat(0);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getaP()) == 1) {
aug1.setaPCallStat(1);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getaP()) == 2) {
aug1.setaPCallStat(2);
}
if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getbP()) == 0) {
aug1.setbPCallStat(1);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getbP()) == 1) {
aug1.setbPCallStat(0);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getbP()) == 2) {
aug1.setbPCallStat(2);
}
}
if ((aug1.cycleRotation == 2)
&& ((aug1.dayOfCycle == 3) || (aug1.dayOfCycle == 0))) {
if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getcP()) == 0) {
aug1.setcPCallStat(1);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getcP()) == 1) {
aug1.setcPCallStat(0);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getcP()) == 2) {
aug1.setcPCallStat(2);
}
if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getdP()) == 0) {
aug1.setdPCallStat(0);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getdP()) == 1) {
aug1.setdPCallStat(1);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getdP()) == 2) {
aug1.setdPCallStat(2);
}
}
if ((aug1.cycleRotation == 3)
&& ((aug1.dayOfCycle == 3) || (aug1.dayOfCycle == 0))) {
if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getaP()) == 0) {
aug1.setaPCallStat(1);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getaP()) == 1) {
aug1.setaPCallStat(0);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getaP()) == 2) {
aug1.setaPCallStat(2);
}
if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getbP()) == 0) {
aug1.setbPCallStat(0);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getbP()) == 1) {
aug1.setbPCallStat(1);
} else if (aug1.determineCallP(aug1.getOnCallCycle(), aug1.getbP()) == 2) {
aug1.setbPCallStat(2);
}
}
}
private String readFile(String pathname) throws Exception {
File file = new File(pathname);
StringBuilder fileContents = new StringBuilder((int) file.length());
Scanner scanner = new Scanner(file);
String lineSeparator = System.getProperty("line.separator");
try {
while (scanner.hasNextLine()) {
fileContents.append(scanner.nextLine() + lineSeparator);
}
return fileContents.toString();
} finally {
scanner.close();
}
}
public void check0(PrintWriter output2, int callStat, String name) {
if (callStat == 0) {
output2.print(name);
output2.println();
}
}
public void check1(PrintWriter output2, int callStat, String name) {
if (callStat == 1) {
output2.print(name);
output2.println();
}
}
public void addDate(OnCallAug812 aug1) {
cal1.add(Calendar.DATE, 1);
aug1.cycleDay = ((cal1.get(Calendar.DAY_OF_YEAR) - 3)) % 16;
aug1.dayOfCycle = cycleDay % 4;
// number of days into current rotation ( 0 =4, 1=1, 2=2, 3=3)
aug1.cycleRotation = (int) (cycleDay / 4);
// number of current rotation (4 per cycle)
aug1.cycleOfYear = ((cal1.get(Calendar.DAY_OF_YEAR) - 2) / 16);
aug1.onCallCycle = cycleOfYear % 4;
}
public static void main(String[] args) throws Exception {
OnCallAug812 aug1 = new OnCallAug812();
aug1.calcCall(aug1);
System.out.print("Day of 16 day rotation(0 to 15): ");
System.out.println(aug1.cycleDay);
System.out.print("Day of 4 day cycle (0 to 3): ");
System.out.println(aug1.dayOfCycle);
System.out.print("Cycle of 16 day rotation (0 to 3): ");
System.out.println(aug1.cycleRotation);
System.out.print("16 day cycle number (0 to 22): ");
System.out.println(aug1.cycleOfYear);
System.out.print("On Call Cycle Number(0 to 6 then repeat): ");
System.out.println(aug1.onCallCycle);
}
public OnCallAug812() {
super();
}
}