HI guys, I need some help with java. I did most of the coding but stuck in dispalying the output graphically. I hope you guys can help me. // Class Course// import java.util.*; public class Course { //Class Variables private int ID = -1; private String NAME = "NULL"; private int CREDITS = -1; private int ENROLLMENT_MIN = -1; private int ENROLLMENT_MAX = -1; private boolean GRADUATE = false; private ArrayList<Student> STUDENTS; //ID Variable Methods public int getID() { return ID; } public void setID(int id) { ID = id; } //Name Methods public String getName() { return NAME; } public void setName(String name) { NAME = name; } //Credit Methods public int getCreditHours() { return CREDITS; } public void setCreditHours(int credits) { CREDITS = credits; } //Enrollment Methods public int getEnrollmentMin() { return ENROLLMENT_MIN; } public void setEnrollmentMin(int min) { ENROLLMENT_MIN = min; } public int getEnrollmentMax() { return ENROLLMENT_MAX; } public void setEnrollmentMax(int max) { ENROLLMENT_MAX = max; } //Graduate Methods public boolean isGraduateLevel() { return GRADUATE; } public void setGraduateLevel(boolean graduate) { GRADUATE = graduate; } //Validation Methods public boolean isValidStudent(Student student) { if(isGraduateLevel() != student.isGraduate()) return false; else if(getStudentCount() >= getEnrollmentMax()) return false; else if(isEnrolled(student)) return false; return true; } public boolean isValidated() { for(int i = 0; i < getStudentCount(); i++) if(!isValidStudent(getStudent(i))) return false; return true; } public boolean isEnrolled(Student student) { try { return getStudents().contains(student); } catch(Exception e) { return false; //No students exist } } //Student Methods public ArrayList<Student> getStudents() { return STUDENTS; } public Student getStudent(int index) { return STUDENTS.get(index); } public void setStudents(ArrayList<Student> students) { STUDENTS = students; enrollStudents(); } public void setStudent(int index, Student student) { STUDENTS.set(index, student); enrollStudents(); } public void addStudent(Student student) { try { STUDENTS.add(student); } catch(Exception e) { Student[] temp = {student}; //Create a singular array List<Student> list = Arrays.asList(temp); //Convert it to a list setStudents(new ArrayList<Student>(list)); //Set it as the students } //enrollStudents(); } //Counting Methods public int getStudentCount() { try { return STUDENTS.size(); } catch(Exception e) { return 0; //No students exist } } //Searching Methods public Student findStudentByID(int id) { for(int i = 0; i < getStudentCount(); i++) if(getStudent(i).getID() == id) return getStudent(i); return null; } public Student findStudentByName(String name) { for(int i = 0; i < getStudentCount(); i++) if(getStudent(i).getName().compareTo(name) == 0) return getStudent(i); return null; } //Other Methods public String toString() { //Outputs in the format: // Name ID \t // [Graduate] (T/F) Min Max \t // [IDs] (1, 2, 3, 4...) String output = ""; output += getName() + " " + getID() + "\t"; output += isGraduateLevel() + " " + getEnrollmentMin() + " " + getEnrollmentMax(); for(int i = 0; i < getStudentCount()-1; i++) output += getStudent(i).getID() + ", "; output += getStudent(getStudentCount()-1).getID(); return output; } public int compareTo(Course course) { if(getID() > course.getID()) return 1; else if(getID() < course.getID()) return -1; else return 0; } private void enrollStudents() { for(int i = 0; i < getStudentCount(); i++) if(!getStudent(i).isEnrolled(this)) getStudent(i).addCourse(this); } } Last edited: 30-Nov-11 10:05 AM
iamunknown · Nov 30, 2011 10:04 AM · 5,950 views
import java.util.*; public class Roster { //Class Variables private ArrayList<Course> COURSES; private ArrayList<Student> STUDENTS; //Course Methods public ArrayList<Course> getCourses() { return COURSES; } public Course getCourse(int index) { try { return COURSES.get(index); } catch(Exception e) { System.out.println("Roster - getCourse(int index)\n\tUnable to call index: " + index + "\n"); return null; } } public void setCourses(ArrayList<Course> courses) { COURSES = courses; updateStudents(); } public void setCourse(int index, Course course) { COURSES.set(index, course); updateStudents(); } public void addCourse(Course course) { COURSES.add(course); updateStudents(); } //Student Methods private void updateStudents() { //ArrayList needs to be initialized with something try { ArrayList<Student> students = getCourse(0).getStudents(); //Add in the students from all of the courses, starting at one for(int i = 1; i < getCourseCount(); i++) for(int k = 0; k < getCourse(i).getStudentCount(); k++) students.add(getCourse(i).getStudent(k)); //Remove the duplicates for(int i = 0; i < students.size(); i++) while(students.lastIndexOf(students.get(i)) != i) students.remove(students.lastIndexOf(students.get(i))); students.trimToSize(); STUDENTS = students; } catch(Exception e) { //Null pointer in case of no courses existing System.out.println("Roster - updateStudents()\n\tUnable to create student list\n"); return; } } public ArrayList<Student> getStudents() { updateStudents(); return STUDENTS; } public Student getStudent(int index) { updateStudents(); try { return STUDENTS.get(index); } catch(Exception e) { System.out.println("Roster - getStudent(int index)\n\tUnable to call index: " + index + "\n"); return null; } } //Counting Methods public int getCourseCount() { try { return COURSES.size(); } catch(Exception e) { return 0; //No courses exist } } public int getGraduateCourseCount() { int count = 0; for(int i = 0; i < getCourseCount(); i++) if(getCourse(i).isGraduateLevel()) count++; return count; } public int getUndergraduateCourseCount() { return getCourseCount() - getGraduateCourseCount(); } public int getStudentCount() { try { updateStudents(); return getStudents().size(); } catch(Exception e) { return 0; //No students exist } } public int getGraduateStudentCount() { int count = 0; for(int i = 0; i < getStudentCount(); i++) if(getStudent(i).isGraduate()) count++; return count; } public int getUndergraduateStudentCount() { return getStudentCount() - getGraduateStudentCount(); } //Searching Methods public Course findCourseByID(int id) { for(int i = 0; i < getCourseCount(); i++) if(getCourse(i).getID() == id) return getCourse(i); return null; } public Course findCourseByName(String name) { for(int i = 0; i < getCourseCount(); i++) if(getCourse(i).getName().compareTo(name) == 0) return getCourse(i); return null; } public Student findStudentByID(int id) { updateStudents(); for(int i = 0; i < getStudentCount(); i++) if(getStudent(i).getID() == id) return getStudent(i); return null; } public Student findStudentByName(String name) { updateStudents(); for(int i = 0; i < getStudentCount(); i++) if(getStudent(i).getName().compareTo(name) == 0) return getStudent(i); return null; } //Validation Methods public ArrayList<Student> findAvailableStudents(Course course) { ArrayList<Student> results = getStudents(); int size = getStudentCount(); for(int i = 0; i < size; i++) if(course.isValidStudent(results.get(i))) { results.remove(i); i--; size--; } results.trimToSize(); return results; } public ArrayList<Course> findAvailableCourses(Student student) { ArrayList<Course> results = getCourses(); int size = getCourseCount(); for(int i = 0; i < size; i++) if(student.isValidCourse(results.get(i))) { results.remove(i); i--; size--; } results.trimToSize(); return results; } //Other Methods public String toString() { updateStudents(); String output = ""; for(int i = 0; i < getStudentCount(); i++) output += getStudent(i).toString() + "\n"; for(int i = 0; i < getCourseCount(); i++) output += getCourse(i).toString() + "\n"; return output; } }
iamunknown · Nov 30, 2011 10:06 AM
import java.util.*; public class Student { //Class Variables private int ID = -1; private String FIRST_NAME = "NULL"; private String MIDDLE_NAME = "NULL"; private String LAST_NAME = "NULL"; private String ADDRESS = "NULL"; private boolean REGISTERED = false; private boolean GRADUATE = false; private ArrayList<Course> COURSES; //ID Methods public int getID() { return ID; } public void setID(int id) { ID = id; } //Name Methods public String getName() { if(MIDDLE_NAME.equals("NULL")) return FIRST_NAME + " " + LAST_NAME; return FIRST_NAME + " " + MIDDLE_NAME + " " + LAST_NAME; } public void setName(String name) { if(name.indexOf(" ") > 0) { if(name.indexOf(" ", name.indexOf(" ")+1) > 0) { setFirstName(name.substring(0, name.indexOf(" "))); setMiddleName(name.substring(name.indexOf(" ")+1, name.indexOf(" ", name.indexOf(" ")+1))); setLastName(name.substring(name.indexOf(" ", name.indexOf(" ")+1))); } else { setFirstName(name.substring(0, name.indexOf(" "))); setLastName(name.substring(name.indexOf(" ")+1)); } } else setFirstName(name); } //First Name Methods public String getFirstName() { return FIRST_NAME; } public void setFirstName(String first) { FIRST_NAME = first; } //Middle Name Methods public String getMiddleName() { return MIDDLE_NAME; } public void setMiddleName(String middle) { MIDDLE_NAME = middle; } public String getMI() { return getMiddleName().charAt(0) + "."; } //Last Name Methods public String getLastName() { return LAST_NAME; } public void setLastName(String last) { LAST_NAME = last; } //Address Methods public String getAddress() { return ADDRESS; } public void setAddress(String address) { ADDRESS = address; } //Registered Methods public boolean isRegistered() { return REGISTERED; } public void setRegistered(boolean registered) { REGISTERED = registered; } //Graduate Methods public boolean isGraduate() { return GRADUATE; } public void setGraduate(boolean graduate) { GRADUATE = graduate; } //Course Variables public ArrayList<Course> getCourses() { return COURSES; } public Course getCourse(int index) { return COURSES.get(index); } public void setCourses(ArrayList<Course> courses) { COURSES = courses; } public void setCourse(int index, Course course) { COURSES.set(index, course); } public void addCourse(Course course) { try { COURSES.add(course); } catch(Exception e) { Course[] temp = {course}; //Create a singular array List<Course> list = Arrays.asList(temp); //Convert it to a list setCourses(new ArrayList<Course>(list)); //Set it as the courses } } //Counting Methods public int getCourseCount() { try { return COURSES.size(); } catch(Exception e) { return 0; //No courses exist } } public int getCreditHours() { int sum = 0; for(int i = 0; i < getCourseCount(); i++) sum += getCourse(i).getCreditHours(); return sum; } public int getCreditLimit() { return isGraduate() ? 12 : 6; //These values are specified by the assignment } //Validation Methods public boolean isValidCourse(Course course) { //Requires proper graduate level and credit count if(isGraduate() != course.isGraduateLevel()) return false; else if(getCreditHours() + course.getCreditHours() > getCreditLimit()) return false; else if(isEnrolled(course)) return false; return true; } public boolean isValidated() { for(int i = 0; i < getCourseCount(); i++) if(!isValidCourse(getCourse(i))) return false; return true; } public boolean isEnrolled(Course course) { try { return getCourses().contains(course); } catch(Exception e) { return false; //No courses exist } } //Searching Methods public Course findCourseByID(int id) { for(int i = 0; i < getCourseCount(); i++) if(getCourse(i).getID() == id) return getCourse(i); return null; } public Course findCourseByName(String name) { for(int i = 0; i < getCourseCount(); i++) if(getCourse(i).getName().compareTo(name) == 0) return getCourse(i); return null; } //Other Methods public String toString() { //Outputs in the format: // Name ID \t // Address \t // [Graduate] [Registered] (T/F) \t // [IDs] (1, 2, 3, 4...) String output = ""; output += getName() + " " + getID() + "\t"; output += getAddress() + "\t"; output += isGraduate() + " " + isRegistered() + "\t"; for(int i = 0; i < getCourseCount()-1; i++) output += getCourse(i).getID() + ", "; output += getCourse(getCourseCount()-1).getID(); return output; } public int compareTo(Student student) { return getLastName().compareTo(student.getLastName()); } }
iamunknown · Nov 30, 2011 10:06 AM
import java.util.*; import java.lang.StrictMath; public class Generator { Random generator = new Random(); //Roster Components public Roster getRoster() { Roster roster = new Roster(); ArrayList<Student> students = new ArrayList<Student>(); ArrayList<Course> courses = new ArrayList<Course>(); //Generate data for(int i = 0; i < 100; i++) students.add(getStudent()); for(int i = 0; i < 20; i++) courses.add(getCourse()); roster.setCourses(courses); //Add in the courses for(int i = 0; i < roster.getCourseCount(); i++) //Loop through the courses { int base = roster.getCourse(i).getEnrollmentMin(); int ceil = roster.getCourse(i).getEnrollmentMax()-base; //Create an array between the min and max enrollment sizes Student[] temp = new Student[generator.nextInt(ceil)+base]; for(int k = 0; k < temp.length;) { Student student = students.get(generator.nextInt(students.size())); //Grab a random student if(roster.getCourse(i).isValidStudent(student)) //See if the student can be added temp[k++] = student; //Add the student } roster.getCourse(i).setStudents(new ArrayList<Student>(Arrays.asList(temp))); } return roster; } //Student Components public Student getStudent() { Student student = new Student(); student.setID(getStudentID(4)); student.setName(getStudentName()); student.setAddress(getStudentAddress()); student.setGraduate(getStudentGraduate()); return student; } public int getStudentID(int length) { //10^length gives me a number starting with one with 'n'-1 remaining 0's //To create a base amount, I add this number to whatever the random number would be //To stay within the length, I create a number with an extra 0 at the end, and subtract 1, giving me 'n' number of 9's //I then subtract the base amount from this number to create my random range of (10000...n to 99999....n) int base = (int)Math.pow(10,length); int ceiling = (int)Math.pow(10,length+1)-1; return generator.nextInt(ceiling-base)+base; } public String getStudentName() { return getStudentFirstName() + " " + getStudentMiddleName() + " " + getStudentLastName(); } public String getStudentFirstName() { String[] first = {"Mohammed", "Ahmed", "Ali", "Ibrahim", "Abdallah", "Khaled", "Sarah", "Mona", "Omar", "Yousef", //10 "Adam", "David", "Eric", "Arthur", "Tobias", "Alexander", "Simon", "Jonas", "Sebastian", "Felix", //20 "Julian", "Ivan", "Nathan", "Lucas", "Thomas", "Louis", "Noah", "Hugo", "Tom", "Gabriel", //30 "Daniel", "Antonio", "Dominik", "Leon", "Oscar","Peter", "Michael", "Jack", "Harry", "Charlie", //40 "William", "Joshua", "George", "James", "Leo", "Robin", "Mathis", "Ethan", "Raphael", "Paul", //50 "Felix", "Ben", "Francesco", "Leonardo", "Nicola", "Gustav", "Robert", "Ryan", "Marian", "Sergey", //60 "Dimitry", "Ivan", "Lewis", "Logan", "Aaron", "Oliver", "Jamie", "Cameron", "Patrick", "Diego", //70 "Mario", "Alejandro", "Pablo", "Mary", "Eva", "Anna", "Hannah", "Sophie", "Julia", "Laura", //80 "Marie", "Alexandra", "Louise", "Clara", "Emma", "Ella", "Elise", "Camille", "Yasmine", "Sara", //90 "Gabriela", "Isabella", "Rebecca", "Lily", "Emily", "Amelia", "Jessica", "Ruby", "Chloe", "Grace", //100 "Daisy", "Alice", "Olivia", "Greta", "Viola", "Lisa", "Venessa", "Lea", "Lucy", "Katie", //110 "Katrina", "Diana", "Victoria", "Pedro", "Mateo", "Luiz", "Benjamin", "Carter", "Jacob", "Mathew", //120 "Alexis", "Justin", "Christopher", "Anthony", "Ashley", "Margaret", "Dorothy", "Elizabeth", "Linda", "Mary", //130 "Madison", "Patricia", "Barbara", "Susan", "Dorothy", "Kayla", "Vivian", "Nicole", "Destiny", "Sophia", //140 "Cooper", "Jackson", "Riley", "Ethan", "Max", "Tyler", "Austin", "Chad", "Christian", "Lloyd", //150 "Summer", "Charlotte", "Angelica", "Angela", "Jasmine", "Kimberly", "Angel", "Jared", "Jonathon", "Nikki"}; //160 return first[generator.nextInt(first.length)]; } public String getStudentMiddleName() { String[] middle = {"Mohammed", "Ahmed", "Ali", "Ibrahim", "Abdallah", "Khaled", "Sarah", "Mona", "Omar", "Yousef", //10 "Adam", "David", "Eric", "Arthur", "Tobias", "Alexander", "Simon", "Jonas", "Sebastian", "Felix", //20 "Julian", "Ivan", "Nathan", "Lucas", "Thomas", "Louis", "Noah", "Hugo", "Tom", "Gabriel", //30 "Daniel", "Antonio", "Dominik", "Leon", "Oscar","Peter", "Michael", "Jack", "Harry", "Charlie", //40 "William", "Joshua", "George", "James", "Leo", "Robin", "Mathis", "Ethan", "Raphael", "Paul", //50 "Felix", "Ben", "Francesco", "Leonardo", "Nicola", "Gustav", "Robert", "Ryan", "Marian", "Sergey", //60 "Dimitry", "Ivan", "Lewis", "Logan", "Aaron", "Oliver", "Jamie", "Cameron", "Patrick", "Diego", //70 "Mario", "Alejandro", "Pablo", "Mary", "Eva", "Anna", "Hannah", "Sophie", "Julia", "Laura", //80 "Marie", "Alexandra", "Louise", "Clara", "Emma", "Ella", "Elise", "Camille", "Yasmine", "Sara", //90 "Gabriela", "Isabella", "Rebecca", "Lily", "Emily", "Amelia", "Jessica", "Ruby", "Chloe", "Grace", //100 "Daisy", "Alice", "Olivia", "Greta", "Viola", "Lisa", "Venessa", "Lea", "Lucy", "Katie", //110 "Katrina", "Diana", "Victoria", "Pedro", "Mateo", "Luiz", "Benjamin", "Carter", "Jacob", "Mathew", //120 "Alexis", "Justin", "Christopher", "Anthony", "Ashley", "Margaret", "Dorothy", "Elizabeth", "Linda", "Mary", //130 "Madison", "Patricia", "Barbara", "Susan", "Dorothy", "Kayla", "Vivian", "Nicole", "Destiny", "Sophia", //140 "Cooper", "Jackson", "Riley", "Ethan", "Max", "Tyler", "Austin", "Chad", "Christian", "Lloyd", //150 "Summer", "Charlotte", "Angelica", "Angela", "Jasmine", "Kimberly", "Angel", "Jared", "Jonathon", "Nikki"}; //160 return middle[generator.nextInt(middle.length)]; } public String getStudentLastName() { String[] last = {"Smith", "Johnson", "Williams", "Brown", "Jones", "Miller", "Davis", "Garcia", "Rodriguez", "Wilson", //10 "Martinez", "Anderson", "Taylor", "Thomas", "Hernandez", "Moore", "Martin", "Jackson", "Thompson", "White", //20 "Lopez", "Lee", "Gonzalez", "Harris", "Clark", "Lewis", "Robinson", "Walker", "Perez", "Hall", //30 "Young", "Allen", "Sanchez", "Wright", "King", "Scott", "Green", "Baker", "Adams", "Nelson", //40 "Hill", "Ramirez", "Campbell", "Mitchell", "Roberts", "Carter", "Phillips", "Evans", "Turner", "Parker", //50 "Collins", "Edwards", "Stewart", "Flores", "Morris", "Nguyen", "Murphy", "Rivera", "Cook", "Rogers", //60 "Morgan", "Peterson", "Cooper", "Reed", "Bailey", "Bell", "Gomez", "Kelly", "Howard", "Ward", //70 "Cox", "Diaz", "Richardson", "Wood", "Watson", "Brooks", "Bennett", "Gray", "James", "Reyes", //80 "Cruz", "Hughes", "Price", "Myers", "Long", "Foster", "Sanders", "Ross", "Morales", "Powell", //90 "Sullivan", "Russel" ,"Ortiz", "Jenkins", "Gutierrez", "Perry", "Butler", "Barnes", "Fisher", "Henderson", //100 "Coleman", "Simmons", "Patterson", "Jordan", "Reynolds", "Hamilton", "Graham", "Kim", "Gonzales", "Alexander", //110 "Ramos", "Wallace", "Griffin", "West", "Cole", "Hayes", "Chaves", "Gibson", "Bryant", "Ellis", //120 "Stevens", "Murray", "Ford", "Marshall", "Owens", "McDonald", "Harrison", "Ruiz", "Kennedy", "Wells", //130 "Alvarez", "Woods", "Mendoza", "Castillo", "Olson", "Webb", "Washington", "Tucker", "Freeman", "Burns", //140 "Henry", "Vasquez", "Snyder", "Simpson", "Crawford", "Jimenez", "Porter", "Mason", "Shaw", "Gordon", //150 "Wagner", "Hunter", "Romero", "Hicks", "Dixon", "Hunt", "Palmer", "Robertson", "Black", "Holmes"}; //160 return last[generator.nextInt(last.length)]; } public String getStudentAddress() { String[] direction = {"", " North", "" , " East", "", " South", "", " West"}; //8 (5) String[] street = {"Main", "Church", "High", "Elm", "Chestnut", "Maple", "Center", "Broad", "Washington", "Walnut", //10 "1st", "2nd", "3rd", "4th", "5th", "Pine", "Water", "Park", "School", "Union", //20 "Oak", "River", "Prospect", "Spring", "Market", "Court", "Front", "Highland", "Cedar", "Spruce", //30 "Central", "Cherry", "State", "Bridge", "Franklin", "Ridge", "Lincoln", "Locust", "Pleasant", "Adams", //40 "Dogwood", "Mill", "Liberty", "Green", "Grove", "Hill", "Hillside", "Broadway", "Elizabeth", "Jefferson", //50 "Academy", "Hickory", "Holly", "Jackson", "Meadow", "Pearl", "Vine", "Arch", "New", "Valley"}; //60 String[] annex = {"Road", "Street", "Boulevard", "Lane", "Avenue", "Parkway", "Court", "Drive"}; //8 return getStudentID(3) + " " + direction[generator.nextInt(direction.length)] + " " + street[generator.nextInt(street.length)] + " " + annex[generator.nextInt(annex.length)]; } public boolean getStudentGraduate() { return generator.nextBoolean(); } //Course Components public Course getCourse() { Course course = new Course(); course.setID(getCourseID()); course.setName(getCourseName()); course.setCreditHours(getCourseCreditHours(course)); course.setEnrollmentMin(getCourseEnrollmentMin()); course.setEnrollmentMax(getCourseEnrollmentMax()); course.setGraduateLevel(getCourseGraduateLevel(course)); return course; } public int getCourseID() { return (generator.nextInt(7)+1)*1000 + (generator.nextInt(5)+1)*100 + generator.nextInt(3)*10 + generator.nextInt(3); } public String getCourseName() { String[] name = {"AP", "ARTS", "ATEC", "BA", "BIOL", "BIS", "BMEN", "CE", "CGS", "CHEM", //10 "CRIM", "CRWT", "CS", "DANC", "DMTH", "DRAM", "ECON", "ECS", "ECSC", "ED", //20 "EE", "EMTH", "ENGR", "FILM", "FIN", "GEOG", "GEOS", "GOVT", "HIST", "MATH", //30 "MECH", "MILS", "MUSI", "NANO", "NSC", "PHIL", "PHYS", "PSCI" ,"PSY", "RHET", //40 "SCE", "SCI", "SE", "SOC", "STAT", "SYSM", "TE", "UNIV"}; //48 return name[generator.nextInt(name.length)]; } public int getCourseCreditHours(Course course) { try <span
iamunknown · Nov 30, 2011 10:07 AM
Continued from Roster class. { return Integer.parseInt((course.getID()+"").charAt(1)+""); } catch(Exception e) { return -1; } } public int getCourseEnrollmentMin() { int[] min = {5,7,10}; //3 return min[generator.nextInt(min.length)]; } public int getCourseEnrollmentMax() { int[] max = {15, 20, 25, 30, 35, 40, 45, 50, 55, 60}; //11 return max[generator.nextInt(max.length)]; } public boolean getCourseGraduateLevel(Course course) { return (Integer.parseInt((course.getID()+"").charAt(0)+"")) > 4; } } //Class Main// import java.util.*; public class Main { public static void main(String[] args) { Generator generator = new Generator(); Roster roster = generator.getRoster(); String output = "COURSE LIST\n\n"; for(int i = 0; i < roster.getCourseCount(); i++) { output += "ID: " + roster.getCourse(i).getID() + "\n"; output += "Name: " + roster.getCourse(i).getName() + "\n"; output += "Graduate Level: " + (roster.getCourse(i).isGraduateLevel() ? "Yes" : "No") + "\n"; output += "Credit Hours: " + roster.getCourse(i).getCreditHours() + "\n"; output += "Enrollment Boundary: " + roster.getCourse(i).getEnrollmentMin() + " to " + roster.getCourse(i).getEnrollmentMax() + "\n"; output += "Student List: "; for(int k = 0; k < roster.getCourse(i).getStudentCount(); k++) output += roster.getCourse(i).getStudent(k).getID() + " "; output += "\n"; output += "\n"; } output += "STUDENT LIST\n\n"; for(int i = 0; i < roster.getStudentCount(); i++) { output += "ID: " + roster.getStudent(i).getID() + "\n"; output += "Name: " + roster.getStudent(i).getName() + "\n"; output += "Address: " + roster.getStudent(i).getAddress() + "\n"; output += "Graduate: " + (roster.getStudent(i).isGraduate() ? "Yes" : "No") + "\n"; output += "Course List: "; for(int k = 0; k < roster.getStudent(i).getCourseCount(); k++) output += roster.getStudent(i).getCourse(k).getID() + " "; output += "\n"; output += "\n"; } GUI.create("School Roster", output); } } Last edited: 30-Nov-11 10:19 AM
iamunknown · Nov 30, 2011 10:08 AM
This is what I did for the GUI. I dont know much about GUI, so stuck now. Please help me import javax.swing.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; public class GUI extends JFrame { public static void create(String title, String text) { GUI frame = new GUI(text); frame.setTitle(title); //Sets the title frame.setSize(640,480); //Sets the size frame.setLocationRelativeTo(null); //Centers the window frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Actually closes the process when prompted frame.setVisible(true);
iamunknown · Nov 30, 2011 10:10 AM
iamunknown · Nov 30, 2011 10:11 AM
थे अस्सिग्न्मेन्त इज तो ग्राफइकल्ली दिस्प्लएे अ सोर्तेद लिस्त अफ रेगिस्तेरेद कोउर्सेस अन्द अ रोस्तेर फोर एअच कुर्‍ेन्त कोउर्से विथ थे नमेस अफ स्टुडेन्टस एन्रोल्लेद इन अ सोर्तेद अर्डर बी लस्त नेम।
iamunknown · Nov 30, 2011 10:16 AM
This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.
Start a New Discussion