Results 1 to 9 of 9
  1. #1
    GRoss is offline Member
    Join Date
    May 2010
    Posts
    8
    Rep Power
    0

    Question Writing to .txt file

    Hi everyone,

    I'm getting close to finishing my Java assignment... as well as 3 other ones (haven't really been sleeping more than 4 hours a day for the last few days) and have come up with another problem.

    The assignment is to design a student enrolment system which allows students to be enrolled into courses, units, it also allows creating new students/courses/units and modifying all of them, reporting, deleting, etc.

    I have 6 classes so far:
    CourseAdmin (Main Class), Course, UndergradCourse, PostgradCourse, Student, Unit.


    The issue that I currently have is that I need to store all of the student, unit and course data to a .txt file, which is easy and then upon the program startup I need to load all of the data in and re-create all of the objects to be exactly the same as the last time, when the program was quit.

    Now.. that seemed like a easy task, until I started coding it - the problem that I have is that all 3 ArrayLists full of objects (units, courses, student) are all inter-related:

    Student will be enrolled into course and in units
    Units will belong to a course
    Course will contain units and student

    ^^
    That is the problem - I do not really understand how to make the connections between the objects, upon program startup...

    Here is writeStudentList() method, which does.. well it does what I want it to do - writes the student details to the StudentList.txt file:

    PHP Code:
    //-------------------------------------------------------------------------------------------------------------------------------------------
    public void writeStudentList()
    	{
    		try
    		{
    			int i = 0;
    			String nullString = null;
    
    			PrintStream outFile = new PrintStream(new File("StudentList.txt"));
    
    			while(studentList.size() != 0 && i < studentList.size())
    			{
    				outFile.println(studentList.get(i).getId());
    				outFile.println(studentList.get(i).getName());
    				outFile.println(studentList.get(i).getCampus());
    				outFile.println(studentList.get(i).getStudentType());
    				outFile.println(studentList.get(i).getEnrolledCourse().getCourseCode());
    
    				//Prints currently enrolled units
    				for(int ii = 0; ii < studentList.get(i).getEnrolledUnits().length; ii++)
    				{
    					if(studentList.get(i).getEnrolledUnits()[ii] != null)
    						outFile.println(studentList.get(i).getEnrolledUnits()[ii].getUnitCode());
    					else
    						outFile.println(nullString);
    				}
    
    				//Prints completed units
    				for(int ii = 0; ii < studentList.get(i).getCompletedUnits().length; ii++)
    				{
    					if(studentList.get(i).getCompletedUnits()[ii] != null)
    						outFile.println(studentList.get(i).getCompletedUnits()[ii].getUnitCode());
    					else
    						outFile.println(nullString);
    				}
    
    				i++;
    			}
    		}
    		catch(FileNotFoundException e)
    		{
    			System.out.println("\"StudentList.txt\" not found!");
    		}
    	}
    And here is my attempt at a readStudentList() method, which well.. doesn't really do anything usefull...:(
    PHP Code:
    	public void readStudentList()
    	{
    		try
    		{
    			String id;
    			String name;
    			String campus;
    			char studentType = 'U';
    			String enrolledCourseCode;
    
    			Unit[] enrolledUnits = new Unit[4];	//currently enrolled units
    			Unit[] completedUnits;	//completed units number depends on the student type
    			Scanner fileScan = new Scanner(new File("StudentList.txt"));
    
    			if(studentType == 'U')
    			{
    				completedUnits = new Unit[24];
    			}
    			else
    			{
    				completedUnits = new Unit[12];
    			}
    
    			while (fileScan.hasNext())
    			{
    				id = fileScan.nextLine();
    				name = fileScan.nextLine();
    				campus = fileScan.nextLine();
    				studentType = fileScan.nextLine().charAt(0);
    				enrolledCourseCode = fileScan.nextLine();
    
    				for(int i = 0; i < enrolledUnits.length; i++)
    				{
    					enrolledUnits[i].setUnitCode(fileScan.nextLine(););
    					//need to set student's enrolledUnits[0] to a unit with unitCode on the line
    					//just scanned, then need to do the same for completed units in the next for loop
    					//but I cannot do that now, because there are no unit objects loaded yet
    					//to set the values of the new units with the unit code jsut defined, to 
    					//previously user-defined values... 8(
    				}
    
    
    			}
    		}
    		catch(FileNotFoundException e)
    		{
    			System.out.println("\"StudentList.txt\" not found!");
    		}
    The problem is that I cannot load the unitList ArrayList of Unit objects first, because each Unit object has an ArrayList of Student objects ..

    ..I cannot load the studentList ArrayList of Student objects first, because each Student object has 2 Arrays of Unit object..

    ..and I cannot load the courseList ArrayList of Course objects first, because each Course has ArrayLists of both Student and Unit objects..


    I am very confused on what to do now - I have read about serialisation, but 1 - I didn't really understand, 2 - I'm not even sure that serialisation is what I need to use...:confused:

    Some advice would be greatly appreciated!!
    Last edited by GRoss; 05-26-2010 at 06:09 PM.

  2. #2
    GRoss is offline Member
    Join Date
    May 2010
    Posts
    8
    Rep Power
    0

    Default

    Also, this is the Beginning of the Driver Class, in case this makes it easier to understand what I am doing..
    PHP Code:
    //--------------------------------------------------------------------------------------------
    public class CourseAdmin
    {
    	private static Scanner scan = new Scanner(System.in);
    	private int menuChoice = 0;
    	String menuChoiceString = "";
    	char menuChoiceChar;
    
    	private static ArrayList<Student> studentList = new ArrayList<Student>();
    	private static ArrayList<Unit> unitList = new ArrayList<Unit>();
    	private static ArrayList<Course> courseList = new ArrayList<Course>();
    
    	private static String input = "";
    	private static String output = "";
    
    	//All of Monash university campuses
    	private final String[] campus = {"CAULFIELD", "CLAYTON", "BERWICK", "GIPPSLAND",
    	 "SOUTH AFRICA", "MALAYSIA"};
    
    
    //---------------------------------------Main Method
    
    	public static void main(String[] args)
    	{
    		CourseAdmin driver = new CourseAdmin();
    		driver.menu();
    	}

  3. #3
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    First of all, you don't need all those get() calls -- you just need one.
    Java Code:
                            ...
    			while(studentList.size() != 0 && i < studentList.size())
    			{
                                    Student s = studentList.get(i);
    				outFile.println(s.getId());
    				outFile.println(s.getName());
    				outFile.println(s.getCampus());
                                    ...
    To help with your readStudentList() method we need to know a little more...

    • What does your Student constructor look like?
    • What does your Unit constructor look like?
    • What does the file look like?

    Whether you're loading Students first or Units first, you'll end up with some empty ArrayLists that you'll need to fill as you go. But it's going to be difficult to explain without seeing more of your code. Show us your Student, Unit and Course classes, and if you can show us a sample of the file you're reading from, that would be great too.

    -Gary-

    EDIT: Never mind that last part -- the file you're reading from is the file you're writing with the writeStudentList() method. Let me look at that a little more closely and I'll get back to you. I do want to see your Student and Unit classes, though.
    Last edited by gcalvin; 05-26-2010 at 06:23 PM.

  4. #4
    GRoss is offline Member
    Join Date
    May 2010
    Posts
    8
    Rep Power
    0

    Default

    Thanks a lot for helping out! I have to warn you - the code is quite messy...
    PHP Code:
    //--------------------------------------Unit Class-------------------------------------
    import java.util.*;
    import java.util.regex.*;
    
    /**
     * @(#)Unit.java
     *
     *
     * @Ross
     * @version 1.00 2010/3/27
     */
    
    
    public class Unit
    {
    	private String unitCode;
    	private String unitName;
    	private char[] availability = new char[6];
    	private ArrayList<Student> studentList = new ArrayList<Student>();
    
    	private int unitLevel;	//1-5 representing units levels 1-5
    
        public Unit()
        {
    		this.unitCode = "N/A";
    		this.unitName = "N/A";
        }
    
        public Unit(String unitCode, String unitName, char[] availability)
        {
        	this.unitCode = unitCode;
        	this.unitName = unitName;
        	this.availability = availability;
        }
    
    //toString Method
    	public String toString()
    	{
    		String toStringUnitCode = ("Unit Code: " + this.unitCode);
    		String toStringUnitName = ("Unit Name: " + this.unitName);
    		String toStringUnitAvailability = ("Unit Availability: ");
    
    		for(int i = 0; i < availability.length; i++)
    		{
    			toStringUnitAvailability = (toStringUnitAvailability + availability[i]);
    		}
    
    		String toString = (toStringUnitCode + toStringUnitName + toStringUnitAvailability);
    
    		return toString;
    	}
    
    //Accessors
    
    	public String getUnitCode()
    	{
    		return unitCode;
    	}
    
    	public String getUnitName()
    	{
    		return unitName;
    	}
    //Mutators
    
    	public void setUnitName(String unitName)
    	{
    		this.unitName = unitName;
    	}
    
    	public void setAvailability(char[] availibility)
    	{
    		this.availability = availability;
    	}
    
    //adds a new student to the student list
    	public void enrollStudent(Student student)
    	{
    		studentList.add(student);
    	}
    
    }
    PHP Code:
    //--------------------------------------Student Class---------------------------------
    import java.util.*;
    /**
     * @(#)Student.java
     *
     *
     * @Ross
     * @version 1.00 2010/3/27
     */
    
    
    public class Student
    {
    	private String name;
    	private char courseStatus;	//A(active)/D(discontinued)/C(completed)
    	private String campus;	//The campus where the student is studying (Only 1 allowed)
    	private Course enrolledCourse;
    
    	private Unit[] enrolledUnits = new Unit[4]; //Currently enrolled in units
    	private Unit[] completedUnits;	//completed units
    
    	private char studentType;	//Undergraduate(U) or postgraduate(P)
    
    	//A collection of all currently used student IDs
    	private static ArrayList<String> idNumbersInUse = new ArrayList<String>();
    	private String individualIdNumber;	//ID number for this student
    
        //Array representing different year levels for units - eg. [0] - level 1, [4] - level 5
        private int[] yearLevelUnits = {0, 0, 0, 0, 0};
    
    //Default constructor
        public Student()
        {
        	courseStatus = 'A';
        	generateStudentId();
        }
    
    //Non-default constructor
    	public Student(String name, char courseStatus, Course enrolledCourse, String campus)
    	{
    		this.name = name;
    
    		if(enrolledCourse instanceof UndergradCourse)
    		{
    			this.studentType = 'U';
    			completedUnits = new Unit[24];
    		}
    		else
    		{
    			this.studentType = 'P';
    			completedUnits = new Unit[12];
    		}
    
    		this.courseStatus = courseStatus;
    		this.enrolledCourse = enrolledCourse;
    		this.campus = campus;
    
    		this.courseStatus = 'A';
    		generateStudentId();
    	}
    
    //toString method
    //code and name of completed units, code and name of currently enrolled units
    	public String toString()
    	{
    		String toString = ("Student ID: " + this.individualIdNumber + "\n" +
    			"Student Name: " + this.name + "\n" + "Course Status: " + this.courseStatus  + "\n"
    			+ "Student Type: " + studentType  + "\n" +
    			"Course ID: " + this.enrolledCourse.getCourseCode()  + "\n" +
    			"Enrolled Units: ");
    
    		//Displays Enrolled Units
    		for(int i = 0; i < enrolledUnits.length; i++)
    		{
    			if(enrolledUnits[i] != null)
    			toString = (toString + "\n\t" + enrolledUnits[i].getUnitCode() + " " +
    				enrolledUnits[i].getUnitName());
    			else
    				i = i;
    		}
    		toString = (toString + "\nCompleted Units: ");
    		//Displays completed units
    		for(int i = 0; i < completedUnits.length; i++)
    		{
    			if(completedUnits[i] != null)
    			toString = (toString + "\n\t" + completedUnits[i].getUnitCode() + " " +
    				completedUnits[i].getUnitName());
    			else
    				i = i;
    		}
    
    
    		return toString;
    	}
    
    //Accessors--------------
    	//returns the student name
    	public String getName()
    	{
    		return name;
    	}
    
    	public String getId()
    	{
    		return individualIdNumber;
    	}
    
    	//returns the student's course status
    	public char getCourseStatus()
    	{
    		return courseStatus;
    	}
    
    	//returns the student's campus
    	public String getCampus()
    	{
    		return campus;
    	}
    
    	//returns the enrolled course code
    	public Course getEnrolledCourse()
    	{
    		return enrolledCourse;
    	}
    
    	//returns the array of enrolled units
    	public Unit[] getEnrolledUnits()
    	{
    		return enrolledUnits;
    	}
    
    	//renturs the number of units in the enrolledUnits array
    	public int getNumberCurrentlyEnrolledUnits()
    	{
    		int i = 0;
    
    		while(enrolledUnits[i] != null && i < enrolledUnits.length)
    		{
    			i++;
    		}
    
    		return i;
    	}
    
    	public Unit[] getCompletedUnits()
    	{
    		return completedUnits;
    	}
    
    	//returs student type
    	public char getStudentType()
    	{
    		return studentType;
    	}
    
    //Mutators---------------
    
    //Sets the courseStatus to the status passed as a paramenter, performing necessary checks
    	public void setCourseStatus(char courseStatus)
    	{
    		if(courseStatus == 'C')
    		{
    			if(unitListHasUnits() == false)
    			{
    				System.out.println("Course status set to Completed!");
    			}
    			else
    			{
    				System.out.println("Error! The student is currently enrolled in 1 or" +
    					" more units!");
    				System.out.println("The student's course status cannot be set to Completed!");
    			}
    		}
    		else
    		{
    			this.courseStatus = courseStatus;
    			System.out.println("Course status set to Discontinued!");
    		}
    	}
    //----------------------------------------------------------------------------------------------
    //Enrolls a student into a unit, checking if the student has at least 1 empty
    //slot in the enrolledUnits array and then checking if the unitCode supplied
    //matched the unitCode of a unit in the CourseAdmin class
    //If error occurs - the method will inform the user
    
    //New version of the enrollInUnit
    public void enrollInUnit(String unitCode)
    	{
    		//if(courseStatus == 'C' || courseStatus == 'D')
    		//System.out.println("The student has either Completed or Discontinued " +
    		//"his/her course. Enrollment failed!");
    
    		int i = 0;
    		int ii = 0;
    
    		while(i < enrolledUnits.length && enrolledUnits[i] != null)
    		{
    			i++;
    		}
    
    		CourseAdmin.getUnitList().get(ii).getUnitCode().equals(unitCode);
    
    		while(!CourseAdmin.getUnitList().get(ii).getUnitCode().equals(unitCode) &&
    				ii < CourseAdmin.getUnitList().size())
    		{
    			ii++;
    		}
    
    		if(CourseAdmin.getUnitList().get(ii).getUnitCode().equals(unitCode))
    			enrolledUnits[i] = CourseAdmin.getUnitList().get(ii);
    		else
    			System.out.println("Critical Error - no such unit in the database!!" +
    				" - enrollInUnits() method");
    
    	}
    
    //Removes a unit specified by the parameter from the enrolledUnits array
    	public void withdrawFromUnit(String unitCode)
    	{
    		int i = 0;
    
    		while(i <= (enrolledUnits.length - 1) &&
    			!enrolledUnits[i].getUnitCode().equals(unitCode))
    		{
    			i++;
    		}
    
    		//If student has such unit then
    		if(enrolledUnits[i].getUnitCode().equals(unitCode))
    		{
    			if(courseStatus == 'C' || courseStatus == 'D')
    				System.out.println("The student has either Completed or Discontinued " +
    					"his/her course. Enrollment failed!");
    			else
    			{
    				enrolledUnits[i] = null;
    				System.out.println("Student successfully withdrawn!");
    			}
    		}
    		else
    			System.out.println("This student is not enrolled into such unit!");
    	}
    
    //---------------------------------------------------------------------------------------------
    
    //Returns true if the student has completed or si currently enrolled in the unit specified by
    //the unitCode passed as the parameter
    	public boolean checkUnitList(String unitCode)
    	{
    		boolean studentHasEnrolledUnit;
    		boolean studentHasCompletedUnit;
    		boolean studentHasUnit;	//true if student has  completed the unit or is currently enrolled
    		int i = 0;
    
    		try
    		{
    			//Checks currently enrolled units
    			while(enrolledUnits.length != 0 && i <= (enrolledUnits.length - 1) &&
    				!enrolledUnits[i].getUnitCode().equals(unitCode))
    			{
    				i++;
    			}
    			if(enrolledUnits[i].getUnitCode().equals(unitCode))
    				studentHasUnit = true;
    			else
    				studentHasUnit = false;
    		}
    		catch(IndexOutOfBoundsException e)
    		{
    			studentHasUnit = false;
    		}
    		catch(NullPointerException e)
    		{
    			studentHasUnit = false;
    		}
    
    		i = 0; //resets the value of i
    
    		try
    		{
    			//Checks completed units
    			while(completedUnits.length != 0 && i <= (completedUnits.length - 1) &&
    				!completedUnits[i].getUnitCode().equals(unitCode))
    			{
    				i++;
    			}
    
    			if(completedUnits[i].getUnitCode().equals(unitCode))
    				studentHasCompletedUnit = true;
    			else
    				studentHasCompletedUnit = false;
    		}
    		catch(IndexOutOfBoundsException e)
    		{
    			studentHasCompletedUnit = false;
    		}
    		catch(NullPointerException e)
    		{
    			studentHasCompletedUnit = false;
    		}
    
    		if(studentHasCompletedUnit == true || studentHasCompletedUnit == true)
    			studentHasUnit = true;
    		else
    			studentHasUnit = false;
    
    		return studentHasUnit;
    	}
    
    //Returns 'true' if unitList for this student has at least 1 unit
    	public boolean unitListHasUnits()
    	{
    		boolean unitListHasUnits;
    		int i = 0;
    
    		while(i <= (enrolledUnits.length - 1) &&
    			enrolledUnits[i] != null)
    		{
    			i++;
    		}
    
    		if(enrolledUnits[i] == null)
    			unitListHasUnits = true;
    		else
    			unitListHasUnits = false;
    
    		return unitListHasUnits;
    
    	}
    
    //Method to check whether the particular student has exceeded the maximum allowed
    //number of units of a particualr unit level, depending on the courseType in which the
    //student is enrolled
    	public void checkUnitLevelAllowance(Unit unit)
    	{
    		try
    		{
    			String unitCode = unit.getUnitCode();
    			//FIT2034  0.1.2|3|4.5.6 - charAt(3) = unitLevel
    			char unitLevel = unitCode.charAt(3);
    
    			if(unitLevel == '1')
    				yearLevelUnits[0]++;
    			else if(unitLevel == '2')
    				yearLevelUnits[1]++;
    			else if(unitLevel == '3')
    				yearLevelUnits[2]++;
    			else if(unitLevel == '4')
    				yearLevelUnits[3]++;
    			else
    				yearLevelUnits[4]++;
    			if(getEnrolledCourse() instanceof UndergradCourse)
    			{
    				/*if(firstYearUnits = 10)
    				{
    
    				}
    				else if()
    				{
    
    				}*/
    			}
    			else	//if PostGrad
    			{
    
    			}
    
    		}
    		catch(InputMismatchException e)
    			{
    				System.out.println("Invalid unit code!");
    			}
    
    	}
    
    //Generates an 8 digit idNumber with 0-9 numeric characters, 8th digit is a check digit.
    //Generates a random UNIQUE studentId
        public String generateStudentId()
        {
        	String idNumber; //The final representation of the student ID
        	int randomId;	//originally generated 7 numbers
        	int checkDigit = 0;
    
        	char[] tempIdChar = new char[10];
        	int[] tempIdInt = new int[10];
        	String tempId;
           	Random random = new Random();
           	int i = 0;	//used for checking the new id against existing ones
           	boolean loop = false;	//if random number already in use, loop
    
    		do
    		{
    			randomId = (random.nextInt(9000000) + 1000000);
    	       	tempId = Integer.toString(randomId);	//String representation of the first 7 numbers
    
    			//Transforms the randomId into 7 chars, which get converted into single integers
    			for(int ii = 0; ii < tempId.length(); ii++)
    			{
    				tempIdChar[ii] = tempId.charAt(ii);
    				tempIdInt[ii] = Character.digit(tempIdChar[ii], 10);
    
    				checkDigit = (checkDigit + tempIdInt[i]);
    			}
    
    			checkDigit = checkDigit % 10;
    			idNumber = (tempId + Integer.toString(checkDigit));
    
    			while(idNumbersInUse.size() != 0 && !idNumber.equals(idNumbersInUse.get(i)) &&
    				i < (idNumbersInUse.size() - 1))
    			{
    				i++;
    			}
    
    			if(idNumbersInUse.size() != 0)
    			{
    				if(idNumbersInUse.get(i).equals(idNumber))
    				{
    					i = 0;
    				}
    				else
    				{
    					idNumbersInUse.add(idNumber);
    					loop = false;
    				}
    			}
    			else
    			{
    				idNumbersInUse.add(idNumber);
    				loop = false;
    			}
    		}
    		while(loop == true);
    
    		individualIdNumber = idNumber;
    		idNumbersInUse.add(idNumber);
    
         	return idNumber;
        }
    
    }

  5. #5
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    OK, the Unit class is not too bad. You have declared a unitLevel field that you don't seem to be using, I don't understand what the availability array is all about, and you have an error in your setAvailability() method that you need to fix, but other than that it looks fine.

    The Student class is another matter. Keep your static variables separate from your instance variables to avoid the risk of confusion. Why in the world would you use Random to create a student ID? Is this a requirement? If not, wouldn't it be simpler to just assign them sequentially? Anyway, that whole method looks much more complicated than it needs to be, but that's beside the point. The bigger issue is that you don't have any method that I can see -- either constructor or setter -- to restore a saved student ID. You have two constructors and they both generate new random student IDs. That's not going to work for you when you're trying to restore. It would be better if your second constructor took an int studentId parameter and simply assigned it. You can still pass generateStudentId() in that parameter from the calling code if you want to.

    You need to be able to write all of your data -- Students, Units and Courses -- to a text file, and then read them back in so that they are restored in exactly the same condition, right? That means that you need to preserve all the state information -- all the fields -- in each object. So whatever you print to the file, you'll need to be able to read it back, parse it, and assign it to the object either with the constructor or with a setter method. Look at the fields that are declared for each class, and make sure they are all covered. I would probably write out Courses first, then Units, and finally Students. I don't have your Course class, so let's talk about the problem of restoring your Units when you don't have your Students restored yet. When you write your Units to your text file, you'll be writing out Student ID numbers. When you read them back in, you need to hang on to them until your Student objects are restored, then go back and match the ID to the Student, and enroll the Student in the Unit. The proper way to do that is with a Map, but I don't know if your course has covered Maps yet -- has it?

    -Gary-

  6. #6
    GRoss is offline Member
    Join Date
    May 2010
    Posts
    8
    Rep Power
    0

    Default

    Thanks again,
    So I understand that I need another constructor, which would be able to accept the student ID as one of parameters, to restore the student ID - I completely forgot to do that 8/..

    As for the ID number generation - I did it sequentially, but the method ended up looking REALLY big, so I got rid of that and replaced it with this one, since my lecturer said that he doesn't care what we do...

    I think I'm starting to understand there (maybe) - so firstly I think that I'll need another arrayList of studenIDs in the Unit class, which would temporarily hold the studentIds, until students are restored, and then have a loop, which would match studentIds to students and put them in studentList arrayList in the UnitClass..... I'll try that as soon as I get back from uni..

    About maps - we have just touched on Maps really quickly, but haven't really done much with them.. I know that a HashMaps can have key mapped to values, but I'm not really sure how would I use that..
    ..wouldn't it be easier to jsut have a loop mapping Students to StudentIds?

    method in CourseAdmin
    PHP Code:
    while(unitList.get(i) != null)
    {
       while(unitList.get(i).getStudentList.get(i) != null)
       {
           //get a student from the studentList and match it to the studentIds for the unit?
       }
    }
    Last edited by GRoss; 05-27-2010 at 03:18 AM.

  7. #7
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Actually, the more I think about it, your Student objects know all of their Units, right? So if you restore all the Units first without restoring their Student arrays, then enroll the Students as you restore them, you'd still have a complete set of information, right?

    If not, you could create and store temporary Student objects when you restore your Unit class -- no names, campuses or anything, just a Student ID -- and then replace them with the real Student objects as those get restored.

    -Gary-

  8. #8
    GRoss is offline Member
    Join Date
    May 2010
    Posts
    8
    Rep Power
    0

    Default

    Each student knows its completed units and currently enrolled units, but the problem might be due to the fact, that a unit can still exists, without any students enrolled into it...
    ..just trying to understand exactly how would this work...

    The 2nd option now is my preference as far as I see it -I'll need to do some paper sketches first to decide I guess - I'm still quite confused... :/

  9. #9
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Quote Originally Posted by GRoss View Post
    Each student knows its completed units and currently enrolled units, but the problem might be due to the fact, that a unit can still exists, without any students enrolled into it...
    ..just trying to understand exactly how would this work...

    The 2nd option now is my preference as far as I see it -I'll need to do some paper sketches first to decide I guess - I'm still quite confused... :/
    You're still going to restore the Units from the text file. We're only talking about the problem of restoring Students to the Units when the Students haven't been restored yet, and I'm suggesting that may not be a problem if the Students simply add themselves to the appropriate Units as they are restored. I could be wrong.

    -Gary-

Similar Threads

  1. writing in file read from another file..
    By UJJAL DHAR in forum New To Java
    Replies: 6
    Last Post: 05-07-2010, 06:41 PM
  2. Replies: 1
    Last Post: 02-27-2010, 02:29 AM
  3. Replies: 9
    Last Post: 10-20-2009, 11:52 AM
  4. Replies: 3
    Last Post: 05-10-2009, 12:31 AM
  5. Replies: 9
    Last Post: 07-10-2008, 05:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •