I have been tasked to create a ClubMember class that represents a member of a fitness club and a tree class to use in the ClubMember class along with a menu that prompts the user to 1) Enter a new member. 2) Display the membership list. 3) Exit the program. I must use a binary search tree to store a set of club members based on their membership ID number and display the membership ID along with the name of the club member. This is what I have so far:
import java.io.*; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class ClubMember { //creates clubMember class/ public static void main(String[] args) { DataOutputStream ostream; final int DONE = 999; int id; String lastName; String firstName; try { ostream = new DataOutputStream (new FileOutputStream("MemID.dat")); System.out.print("Enter ID number or " + DONE + " to quit >> "); //id = input.nextInt(); while(id != DONE) { //input.nextLine(); System.out.print("Enter last name >> "); //lastName = input.nextLine(); System.out.print("Enter first name >> "); firstName = input.nextLine(); ostream.writeInt(id); ostream.writeUTF(lastName); ostream.writeUTF(firstName); System.out.print("Enter ID number or " + DONE + " to quit >> "); id = input.nextInt(); } ostream.close(); } catch(IOException e) { System.err.println("Error opening file"); } catch(InputMismatchException e) { System.err.println("Invalid data entry"); } } }
I'm not sure where to place the menu or the binary search tree, could anyone give me a hand? Thanks