I'm working on a project where I need to import data about members and tickets from a text file into a SortedLinkedList, which is an extension of a LinkedList. I'm feeling really stuck on how to accomplish this and how to ensure the SortedLinkedList works seamlessly with my other classes (MainProgram, Members, and Tickets) that need to interact with it by adding and removing tickets from members. This is my first significant challenge in Java, and I'm at my wits' end! Any guidance would be greatly appreciated.
1 Answer
To tackle your project, here are the key steps you might consider:
1. **Reading from a File**: Start by looking into Java File I/O to understand how to read data from text files. You’ll need classes like `File`, `FileNotFoundException`, and `Scanner`.
2. **Parsing the Data**: Once you've read the file, create a method to parse the data and return a populated `SortedLinkedList`. You can call this method right from your main program.
3. **Adding Methods**: Finally, ensure your `SortedLinkedList` class has methods for adding and subtracting members/tickets, making it easier for main interactions.

I feel you on the file restrictions! You can definitely manage it. Just make sure your `SortedLinkedList` class can handle reading its own data correctly and integrates with the `Scanner` for parsing. It might take a bit of tweaking, but you can streamline the imports within that one file.