我有一个带有两个类Lecturer和Subject的时间表项目,还指定了已知对象。一种可以创建对象的类方法
,他们都必须在对象的数组或ArrayList中
,项目应让用户能够创建或添加,删除,搜索和类讲师的更新对象。
我真的不知道如何去了解这一点,我可以创建一个可以做这个任务上面它应该是一个类的方法,或在主类中的方法的方法?
我该如何让用户能够使用方法或任何其他方式创建对象?
我创建了类,对象和ArrayList我坚持
对不起我能也可以由用户到ArrayList中添加创建的对象是,甚至有可能?
class Lecturer {
static int lec_id;
static String lec_name;
static String lec_rank;
static int lec_salary;
static String lec_department;
}
class Subject { /* initialisation for the class subject*/
String sub_code;
String sub_name;
String sub_department;
int sub_lec_id; /*sub lec id represent the lecturer taking the subject*/
String sub_day;
String sub_time;
String sub_venue;
}
/* intialisation for the class lecturer*/
public class Timetable {
public static void main(String[] args) {
/* the code below represent a created list of objects */ /* `Lecturer l =Lecturer()(System.in);*/`
Lecturer l1 =new Lecturer (1, "Dadson", "Dr", 8000, "Computing");
Lecturer l2 =new Lecturer (2, "Hall", "Prof", 12000, "Computing");
Lecturer l3 =new Lecturer (2, "Berry", "Dr", 7500, "Computing");
Lecturer l4 =new Lecturer (2, "Bull", "Dr", 9000, "Engineering");
Lecturer l5 =new Lecturer (2, "Viles", "Prof", 13500, "Engineering");
Lecturer l6 =new Lecturer (2, "Dyson", "Dr", 7200, "Engineering");
/*The code below represent the array list holding objects of the class Lecturer*/
List<Lecturer> L=new ArrayList<Lecturer>();
L.add(l1);
L.add(l2);
L.add(l3);
L.add(l4);
L.add(l5);
L.add(l6);
/* the code below is to create the object for the class Subject*/
Subject s1=new Subject ("EC3000", "Computing Basics", "Computing", 1, "Mon", "8-10am", "S310");
Subject s2=new Subject ("EE3000", "Engineering Basics", "Engineering", 2, "Tuesday", "10-12pm", "S310");
Subject s3=new Subject ("EC3100", "Programming Fundamentals", "Engineering", 1, "Monday", "1-3pm", "S203");
Subject s4=new Subject ("EE3100", "Engineeering Math", "Computing", 4, "Thursday", "3-5pm", "s420");
Subject s5=new Subject ("EC3200", "Problem Solving", "Computing", 3, "Friday", "8-10pm", "S208");
Subject s6=new Subject ("EE3200", "Circuit", "Enginerring", 4, "Monday", "10-12pm", "S104");
Subject s7=new Subject ("EC3300", "Networking", "Computing", 2, "Tuesday", "1-3pm", "S310");
Subject s8=new Subject ("EE3300", "Electromagnetic", "Engineering", 5, "Wednesday","1-3pm", "S330");
Subject s9=new Subject ("EC3400", "Project", "Computing", 3, "Thursday", "3-5pm", "S312");
Subject s10 =new Subject("EE3400", "Project", "Engineering", 6, "Tuesday", "10-12pm", "S415");
/*The code below represent the array list holding objects of the class Subject*/
Subject[]S=new Subject[10];
S[0]=s1;
S[1]=s2;
S[2]=s3;
S[3]=s4;
S[4]=s5;
S[5]=s6;
S[6]=s7;
S[7]=s8;
S[8]=s9;
S[9]=s10;
}
}
我们无法真正为你做你的工作。我们能做的就是看看你已经尝试过的代码并就事情提供建议。所以,如果你可以请发布代码,你尝试创建一个新的对象。 – 2013-03-17 17:55:11
继承人的代码.... Thankxxx – adrain 2013-03-17 18:09:31
而不是只是downvoting和关闭,我们如何给这个新用户有机会先解决他的问题? – 2013-03-17 18:10:00