/*
* You should give your class a package as it is truely frowned upon these days
* to place your classes in the "main" namespace.
*/
import javax.swing.*;
public class pro1111 {
public static void main (String [] args) {
/*
* I assume you have your own TextFileInput and TextFileOutput
* classes as these are no part of the JDK. And if so, you have not
* imported them.
*/
TextFileInput in = new TextFileInput("Dates.txt");
TextFileOutput out = new TextFileOutput("Dates1.txt");
String line = in.readLine(); // I also assume these classes handle the exceptions
while ( line != null ) {
// StringTokenizer is a bit old fashioned. You should probably look into
// Scanner and or String.split(). But what you really want is to simply read
// the entire String and not break it down into pieces.
StringTokenizer st = new StringTokenizer(line, "/");
int monthNumber = Integer.parseInt(st.nextToken());
int day = Integer.parseInt(st.nextToken());
int year = Integer.parseInt(st.nextToken());
out.println(monthNumberToName(monthNumber) + " " + day + ", " + year);
// You should also be storing the dates here rather than simply printing them
// out. Probably with an ArrayList. Then, after you have them read in and
// stored somewhere, you can start using another loop or two to compare them
// and get them into the proper order.
line = in.readLine();
}
}
private static compareDate(string date1, string date2) {
// Why do you designate two dates (in String format and it should be String not
// string) and then define two new date Strings. You also have not defined a
// return type.
String date1 = "09/27/2004";
String date2 = "05/04/2002";
// calling compareDate here is recursion. Is this really what you want to do?
// I don't think so. Also, doing it when the method defines it own date Strings
// guarntees infinite recursion.
if (compareDate(date1, date2) < 0)
System.out.println("date1 is earlier than date2.");
return 0;
}
private static void display(short[] numbers, int lengthFilled) {
// Why are the declared arguments here a short array and an int when according
// to your assignment it should be a String array (and suppossedly of student
// names which I don't understand at all since the entire has been concerning
// dates up until this point. I think you copied that wrong.) and an int.
// Other than that, this method actually looks like it might do something for
// you. Where did you copy it from?
final String lineBreak = System.getProperty("line.separator");
// Create text area for output:
JTextArea textArea = new JTextArea();
textArea.setEditable(false);
// Print numbers to output text area:
for ( int i = 0; i < lengthFilled; i++ )
textArea.append(numbers[i] + lineBreak);
// Display the output text area via a message dialog box:
JOptionPane.showMessageDialog(null, textArea);
}
/*
* Where are all the rest of the listed methods? Should they generate
* themselves? Really, you could at least put a few skeleton methods for
* them in here so that it at least looks like you tried. You also have not
* placed a closing brace "}" for your class.
*/