This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
After breaking it up using StringTokenizer, how do I return it into chronological order?
Return the schedule for each day of the week as a String with the appointments listed in chronological order, starting with those for the first day of the week and ending with those for the last day of the week. The String should have the following format Sunday: ^14%Paul's house?Group Meeting Monday: ^9%Nutty Professor's Office?Office Hours Tuesday: ^12%MegaBits?Lunch Wednesday: xxx Thursday: xxx Friday: xxx Saturday: xxx
xxx is the String representation of the schedule for each day. There should be no newline after the last schedule. Note: if there are no appointments scheduled for a certain day, then that day should not be included in the String. (For example, if there are no appointments scheduled on Tuesday then: Tuesday: xxx
The code that parses the full String could use a StringBuffer to build the final String to return, assuming the input String is in chronological order itself. Your example implied it is, and didn't demonstrate how to show an empty day.
If it's not in order, you can create an intermediate data structure to hold and reorder the appointments. What constitutes an appointment? Write a class to manage that information. You can use the built-in Collection classes (List, Map, Set) to work with your Appointment class.
It will help you more if you try out some techniques, post your code and ask specific questions.