Yahoo Clever wird am 4. Mai 2021 (Eastern Time, Zeitzone US-Ostküste) eingestellt. Ab dem 20. April 2021 (Eastern Time) ist die Website von Yahoo Clever nur noch im reinen Lesemodus verfügbar. Andere Yahoo Produkte oder Dienste oder Ihr Yahoo Account sind von diesen Änderungen nicht betroffen. Auf dieser Hilfeseite finden Sie weitere Informationen zur Einstellung von Yahoo Clever und dazu, wie Sie Ihre Daten herunterladen.
how would you make a dynamic field?
Hi, I am making a MVC model in java. I have a class called class1
Using UI when i add a course by filling some parametre, this course will be added in Program object. When i add course second time, the first one is gone and second one is the first one. It is hard for me to initialise Course object many times for the new courses to be added. Can any one tell me how to do it
My code is here
public class Initialiser {
private AMSFacade facade;
private String courseType;
private String courseCode;
private String courseTitle;
private String[] Prerequsite;
private ElectiveCourse electiveCourse1;
private CoreCourse coreCourse1;
private Program program;
private Course[] course= new Course[100];
private int count = 0;
public Initialiser() {
}
public void addProgram(String code, String title) {
facade = new AMSFacade();
program = new Program(code, title);
facade.addProgram(program);
}
public void addCourse(String couseType, String courseCode, String title,
String[] prerequsite) {
facade = new AMSFacade();
addProgram("COSC", "ComputerScience");
System.out.println(prerequsite + "prerequsite" + courseTitle);
if (couseType.compareTo("elective") == 0) {
course[count] = new ElectiveCourse(courseCode, title, prerequsite);
courseUpdate(new ElectiveCourse(courseCode, title, prerequsite));
count++;
} else {
course[count] = new CoreCourse(courseCode, title, prerequsite);
courseUpdate(new CoreCourse(courseCode, title, prerequsite));
count++;
}
}
public void courseUpdate(Course course) {
try {
facade.addCourse(course);
} catch (ProgramException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I have an array of Course so whenever i use addCourse method, the course should add to the array using CourseUpdate method there.
But this doesnt work, i can only see one method when i call the method .getAllCourse.length
}
1 Antwort
- TheMadProfessorLv 7vor 1 JahrzehntBeste Antwort
You need two classes here - one of individual objects and a second container class to hold your array, count, etc.