[Show all top banners]

iamunknown
Replies to this thread:

More by iamunknown
What people are reading
Subscribers
Subscribers
[Total Subscribers 1]

EastSidaz
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 help with java assignment
[VIEWED 3234 TIMES]
SAVE! for ease of future access.
Posted on 11-30-11 10:06 AM     [Snapshot: 5]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

 
 
 
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;
}
}

 
Posted on 11-30-11 10:06 AM     [Snapshot: 7]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

 
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());
}
}

 
Posted on 11-30-11 10:07 AM     [Snapshot: 12]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

 
 
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
{
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;
}
}

 
Posted on 11-30-11 10:08 AM     [Snapshot: 19]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

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

 
Posted on 11-30-11 10:10 AM     [Snapshot: 21]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

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);

 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 7 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration case still pending ..
nrn citizenship
emergency donation needed
ढ्याउ गर्दा दसैँको खसी गनाउच
मन भित्र को पत्रै पत्र!
जाडो, बा र म……
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters