Page 2 of 2 First 12
  • Jump to page:
    #16
  1. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    Is mycalender.txt initially empty?
  2. #17
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    15
    Rep Power
    0
    Originally Posted by bullet
    Is mycalender.txt initially empty?
    No, but I got it figured out and working (somehow). Now I'm just having issues with printing out the calendar appointments...

    I have the following method
    Code:
    public static void printAppointmentCalendar(ArrayList<String> appointmentList){
    		ArrayList<String> a = new ArrayList();
    		a = appointmentsOnDay(appointmentList,"Monday");
    		System.out.print("Monday");
    		for(int i = 0; i < a.size(); i++){
    			System.out.println(a.get(i));
    		}
    		System.out.println();
    		a = appointmentsOnDay(appointmentList,"Tuesday");
    		System.out.print("Tuesday");
    		for(int i = 0; i < a.size(); i++){
    			System.out.println(a.get(i));
    		}
    		System.out.println();
    		System.out.println();
    		a = appointmentsOnDay(appointmentList,"Wednesday");
    		System.out.print("Wednesday");
    		for(int i = 0; i < a.size(); i++){
    			System.out.println(a.get(i));
    		}
    		System.out.println();
    		System.out.println();
    		System.out.println();
    		a = appointmentsOnDay(appointmentList,"Thursday");
    		System.out.print("Thursday");
    		for(int i = 0; i < a.size(); i++){
    			System.out.println(a.get(i));
    		}
    		System.out.println();
    		System.out.println();
    		System.out.println();
    		a = appointmentsOnDay(appointmentList,"Friday");
    		System.out.print("Friday");
    		for(int i = 0; i < a.size(); i++){
    			System.out.println(a.get(i));
    		}
    		System.out.println();
    		System.out.println();
    		System.out.println();
    		a = appointmentsOnDay(appointmentList,"Saturday");
    		System.out.print("Saturday");
    		for(int i = 0; i < a.size(); i++){
    			System.out.println(a.get(i));
    		}
    		System.out.println();
    		System.out.println();
    		System.out.println();
    		a = appointmentsOnDay(appointmentList,"Sunday");
    		System.out.print("Sunday");
    		for(int i = 0; i < a.size(); i++){
    			System.out.println(a.get(i));
    		}
    		System.out.println();
    		
    	}
    When prompted it supposed to print out Monday-Sunday and the appointments for those days. I have the following in the main method
    Code:
    else if(userInput.equalsIgnoreCase("printAll")){
     appointmentList.length(); i++){
    					System.out.println(readFromFile());
    				}
    When I use the method it just repeats the days and won't stop. What am I missing to fix this? I'm sure it's really simple and I'm just not thing of it right now.
  4. #18
  5. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    won't stop
    Do you mean the code is in an infinite loop?
    What variables control the looping? Do their values change so the loop will end?
  6. #19
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    15
    Rep Power
    0
    Originally Posted by NormR
    Do you mean the code is in an infinite loop?
    What variables control the looping? Do their values change so the loop will end?
    Yes, as in an infinite loop. As for the values, they don't change. The values are being grabbed from the file. It is supposed to be like:

    Monday 4PM, 5PM
    Tuesday 8PM, 4PM
    Wednesday
    Thursday 5PM
    Friday
    Saturday
    Sunday

    If there aren't any appointments it still shows them, but just doesn't have the times added
  8. #20
  9. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    the values, they don't change
    If the values of the variables that control the looping don't change then the loop will go forever.
    There needs to be code inside the loop the changes the values of the loop control variable to keep the loop from going forever.
    For example this loop will go forever:
    Code:
    int x = 1;
    while (x < 5) {
       y = y + 2;
    } //  end while()
    The value of x needs to be changed for the loop to end.
    Last edited by NormR; April 24th, 2013 at 08:49 PM.
  10. #21
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    15
    Rep Power
    0
    Originally Posted by NormR
    If the values of the variables that control the looping don't change then the loop will go forever.
    There needs to be code inside the loop the changes the values of the loop control variable to keep the loop from going forever.
    I'm thinking of doing a for loop
    for(int i = 0, i < ?; i++){
    System.out.println(readFromFile());
    }

    But I just can't figure out what I should replace the ? with
  12. #22
  13. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    How many times do you want the loop to go around?
  14. #23
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    15
    Rep Power
    0
    Until it hits Sunday and has printed the time (if any), but I'm sure it has to deal with one of my methods. I just don't know which one it is
  16. #24
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    15
    Rep Power
    0
    I submitted it, thanks for all of the help! Much appreciated!
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo