Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
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 Answer
- TheMadProfessorLv 71 decade agoFavorite Answer
You need two classes here - one of individual objects and a second container class to hold your array, count, etc.