Linked list of arrays Java help
As I understand it, your structure is
- BedAndBreakfast class contains all the state for a particular B&B
- Array class contains an array of BedAndBreakfast instances
- Node class which contains an instance of Array as well as (a pointer to) the successor (and maybe predecessor too if it's a doubly linked list)
- List class which has (a pointer to) the first Node
In your description, it sounds like you are just using the array as an implementation for a list, so there's no additional semantics aside from the order that the elements appear (aka if two things being in the same array or different arrays is irrelevant). If that is the case, I would suggest putting the add method in the List class, which means that you can change the internal implementation of the list without affecting any of the users. In general, the instances of Node and Array should not be accessible to users of the class - they should just modify your list via the interface provided by List.
Normally I would suggest implementing the List interface, but if it's an assignment then I presume the person who designed the course knows that they're doing, and you will cover all the relevant stuff.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now