谈到Java时,我知道如何计算大多数事情,但是这要么困扰了我很多,要么我的大脑正在死亡。无论如何,我有一个名为“Jobs”的类,在该类中是一个名为“day”的String变量。已经创建了多个新作业(确切的编号是未知的),现在我需要查询并了解每天有多少个作业。我认为这会很容易,但我不知道如何创建一个从整体看待乔布斯而不是一个特定的乔布斯。Java:数据在一个类中出现次数的计数
作业数据是通过扫描器读取文件(其名称是jobFile)而创建的。
public class Job_16997761 {
private int jobID; // unique job identification number
private int customerID; // unique customer identification number
private String registration; // registration number for vehicle for this job
private String date; // when the job is carried out by mechanic
private String day; // day of the week that job is booked for
private double totalFee; // total price for the Job
private int[] serviceCode; // the service codes to be carried out on the vehicle for the job
//Constructor
public Job_16997761(int jobID, int customerID, String registration,
String date, String day, double totalFee, int[] serviceCode) {
this.jobID = jobID;
this.customerID = customerID;
this.registration = registration;
this.date = date;
this.day = day;
this.totalFee = totalFee;
this.serviceCode = serviceCode;
}
尝试发布一些代码,如“Jobs”类。此外,如何创建'Jobs',并在应用程序中存在哪些位置(例如:谁知道它们存在)? – 2014-10-22 07:10:22
如果你想得到准确的答案,我建议你发布一些代码。 – ortis 2014-10-22 07:10:23
你有没有类似'List'的地方,所有'Job'都被引用? – Steffen 2014-10-22 07:15:05