Desperately need some help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cschuy2006
    New Member
    • Oct 2007
    • 1

    #1

    Desperately need some help

    Lucy
    1 1 1 3 2 3 3 1
    3 3 3 3 2 2 2 2
    2 2 2 2 2 3 3 3
    3 3 3 3 2 3 3 3
    1 1 2 3 2 3 3 2
    John
    3 3 3 3 3 3 3 3
    1 3 3 3 2 2 2 3
    2 2 2 2 2 3 2 1
    1 3 3 3 2 3 2 1
    3 1 2 2 2 1 3 1
    Aaron
    3 3 3 3 3 3 3 3
    1 1 3 3 2 2 3 2
    1 1 2 2 3 2 3 1
    1 3 3 3 2 3 1 3
    1 1 2 3 3 1 2 2
    Rachel
    1 1 1 3 2 3 3 1
    3 3 2 3 2 2 2 2
    2 2 2 2 2 2 2 2
    3 3 3 3 2 3 3 3
    2 2 2 3 2 2 2 2
    Michael
    3 3 3 3 3 3 3 3
    3 3 3 1 3 3 3 3
    3 3 3 3 3 3 3 3
    2 2 2 2 3 3 3 1
    1 1 2 3 2 2 2 1
    MeetingRoom1
    3
    1 1 1 3 1 3 3 1
    3 1 3 1 1 1 1 1
    3 3 1 1 1 1 1 1
    1 1 3 3 1 1 1 1
    1 1 1 3 1 3 1 1
    MeetingRoom2
    15
    1 1 1 3 1 3 3 1
    3 1 3 3 1 1 1 1
    3 3 1 1 1 1 1 1
    1 1 3 3 1 1 1 1
    1 1 1 3 1 3 1 1
    meeting
    Tuesday
    11:00
    Rachel 2 Michael 1
    meeting
    Tuesday
    11:00
    MeetingRoom2
    Rachel 2 John 1
    meeting
    Tuesday
    12:00
    MeetingRoom2
    Lucy 1 Aaron 1 Rachel 2 John 1
    meeting
    Tuesday
    11:00
    MeetingRoom1
    Lucy 1 Aaron 1 Rachel 1

    This is what is in my Array called File
    And this is my code to create meeting objects and add them to a linkedList
    [CODE=java] if(file[i].startsWith("me eting"))
    {
    String venue;
    String day = file[i+1];
    String time = file[i+2];
    if(file[i+3].startsWith("Me etingRoom"))
    {
    venue = (file[i+3]);
    String attendees = file[i+4];
    String []tokens3 = file[i+4].split(" ");
    int x = (tokens3.length )/2;
    String [] compnprefAttend = new String[x];
    String [] originalAvail = new String[x];
    for(int b = 0; b < compnprefAttend .length; ++b)
    {
    String t = tokens3[2*b];
    compnprefAttend[b] = t;
    String w = tokens3[2*b+1];
    originalAvail[b] = w;
    }
    Meeting m = new Meeting(compnpr efAttend, originalAvail, day, time, venue);
    if(firstMeeting )
    {
    meetingsList = new ListOfTables(m) ;
    firstMeeting = false;
    }
    else
    {
    meetingsList.ad dMeeting(m);
    }

    i = i + 4;
    }
    else
    {
    venue = null;
    String attendees = file[i+3];
    String []tokens3 = file[i+3].split(" ");
    int x = (tokens3.length )/2;
    String []compnprefAttend = new String[x];
    String []originalAvail = new String[x];
    for(int b = 0; b < compnprefAttend .length; ++b)
    {
    String t = tokens3[2*b];
    compnprefAttend[b] = t;
    String w = tokens3[2*b+1];
    originalAvail[b] = w;
    }i = i + 3;

    Meeting m = new Meeting(compnpr efAttend, originalAvail, day, time, venue);
    if(firstMeeting )
    {
    meetingsList = new ListOfTables(m) ;
    firstMeeting = false;
    }
    else
    {
    meetingsList.ad dMeeting(m);
    }
    }
    }
    I then use this code to get them out of the linkedList and into another array
    Meeting m = meetingsList.ge tMeetingStart() ;
    int i = 0;
    for(; m != null; m = m.getNext())
    ++i;
    Meeting []meetings = new Meeting[i];
    m = meetingsList.ge tMeetingStart() ;
    for(int j = 0; j < meetings.length ; ++j)
    {
    meetings[j] = m;
    m = m.getNext();
    }
    return meetings;
    I then rewrite them to another file
    if(meetingsList != null)
    {
    Meeting meetings[] = meetings();
    System.out.prin tln(meetings.le ngth);
    for(int i = meetings.length-1; i >= 0; --i)
    {
    out.write("meet ing"+"\n");
    String day = meetings[i].getDay();
    out.write(day+" \n");
    String time = meetings[i].getTime();
    out.write(time+ "\n");
    String venue = meetings[i].getVenue();
    if(venue != null)
    {
    out.write(venue +"\n");
    }
    String compnprefAttend[] = meetings[i].getAttendents( );
    String originalAvail[] = meetings[i].getAvailabilit y();
    for(int j = 0; j < compnprefAttend .length; ++j)
    {
    out.write(compn prefAttend[j]+" "+originalA vail[j]+" ");
    }
    out.write("\n") ;
    }[/CODE]
    What is happening is that it appears to creating a new List with every Meeting Object it finds because when i open up the file it has written to there is only the last meeting Object in the file, However when I have put in some System.out.prin tln() statements to determine what part of the list it is getting into it appears that wit the first Object it finds it creates the list and then just adds the rest to the list
    Any help will be Much appreciated
    Thanks
    Last edited by acoder; Oct 19 '07, 01:44 PM. Reason: Added code tags
  • Logician
    New Member
    • Feb 2007
    • 210

    #2
    Originally posted by cschuy2006
    Any help will be Much appreciated
    Try a comparison between the name of the language you're using, and the title of this forum.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Originally posted by Logician
      Try a comparison between the name of the language you're using, and the title of this forum.
      Moved to the Java forum.

      The title needs a change which I'll leave to the Java mods.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by cschuy2006
        Lucy
        1 1 1 3 2 3 3 1
        3 3 3 3 2 2 2 2
        2 2 2 2 2 3 3 3
        3 3 3 3 2 3 3 3
        1 1 2 3 2 3 3 2
        Care to explain what all these numbers are all about and what your program is
        supposed to solve? Please no code, just a short description of the problem.

        kind regards,

        Jos

        Comment

        Working...