Question
Menu Implementation (ADT Implementation Using Arrays) Summary Implement the MenuInterface interface using an array. (NOT an ArrayList or any other data structure.) Your implementation must
Menu Implementation (ADT Implementation Using Arrays) Summary Implement the MenuInterface interface using an array. (NOT an ArrayList or any other data structure.) Your implementation must provide suitable code for each of the operations in that interface, and also seven (7) constructors (see below). Details I have provided you with an interface that's based on Dr. Scobey's Menu class. It is, however, slightly different. I have also provided you with a sample client program. You SHOULD NOT modify those files. More about the menu class: A menu is a list of options that the user may choose from. The menu optionally has a title that appears at its top. Our menus' options will be numbered, and the user will choose an option by typing in the corresponding number at a prompt. The getChoice method gives the user three chances to enter a valid choice, prompting for each input. If a valid choice gets entered, it is returned immediately. If no valid choice is entered in three tries, the method returns -1. Typing a non-integer at the prompt results in the method returning -1 immediately. The input stream should be left unchanged. Your job is to create an array-based implementation of the MenuInterface. Your implementation must be called ArrayMenu. Much of the code you need can be copied (and lightly modified) from the ArrayBag class provided in the sample code. Note that the Menu should not grow. Once all available slots have been filled in, any attempt to add an option will fail. Make sure your implementation is correct according to all behaviours described in the interface documentation. You must provide the following constructors: A constructor that takes a title, an array of String (the options), and an integer giving the maximum number of options that this Menu can be given. A constructor that takes a title and an array of Strings (which are the options for this menu). A constructor that takes just a title. A constructor that takes just an array of Strings (which are the options for this menu). A constructor that takes a title and an int value (which is the maximum number of options for this menu -- attempting to add more options than that will fail). A constructor that takes just an int value (again, the the maximum number of options). A no-arguments constructor. If no title is provided, then the menu has no title. If no options are provided, the menu starts with no options. If no maximum size is given, then either: an array of options has been given, and that is the maximum number of options for the array; or no array of options has been given, and a default maximum number of options is given. The title may be null, but the array of starting options can't be. If any constructor is given null where an array of options is expected, it should throw a NullPointerException. If the maximum number of options is less than the number of starting options, then the constructor should throw an IllegalArgumentException with a suitable message.
Summary Implement the MenuInterface interface using an array. (NOT an ArrayList or any other data structure.) Your implementation must provide suitable code for each of the operations in that interface, and also seven (7) constructors (see below). Details have provided you with an interface that's based on Dr. Scobey's Menu class. It is, however, slightly different. have also provided you with a sample client program. You SHOULD NOT modify those files. More about the menu class: - A menu is a list of options that the user may choose from. The menu optionally has a title that appears at its top. - Our menus' options will be numbered, and the user will choose an option by typing in the corresponding number at a prompt. - The getChoice method gives the user three chances to enter a valid choice, prompting for each input. If a valid choice gets entered, it is returned immediately. If no valid choice is entered in three tries, the method returns 1. - Typing a non-integer at the prompt results in the method returning -1 immediately. The input stream should be left unchanged. Your job is to create an array-based implementation of the MenuInterface. Your implementation must be called ArrayMenu. Much of the code you need can be copied (and lightly modified) from the ArrayBag class provided in the sample code. Note that the Menu should not grow. Once all available slots have been filled in, any attempt to add an option will fail. Make sure your implementation is correct according to all behaviours described in the interface documentation. You must provide the following constructors: - A constructor that takes a title, an array of String (the options), and an integer giving the maximum number of options that this Menu can be given. - A constructor that takes a title and an array of Strings (which are the options for this menu). - A constructor that takes just a title. - A constructor that takes just an array of Strings (which are the options for this menu). - A constructor that takes a title and an int value (which is the maximum number of options for this menu -- attempting to add more options than that will fail). - A constructor that takes just an int value (again, the the maximum number of options). I have also provided you with a sample client program. You SHOULD NOT modify those files. More about the menu class: - A menu is a list of options that the user may choose from. The menu optionally has a title that appears at its top. - Our menus' options will be numbered, and the user will choose an option by typing in the corresponding number at a prompt. - The getChoice method gives the user three chances to enter a valid choice, prompting for each input. If a valid choice gets entered, it is returned immediately. If no valid choice is entered in three tries, the method returns 1. - Typing a non-integer at the prompt results in the method returning 1 immediately. The input stream should be left unchanged. Your job is to create an array-based implementation of the MenuInterface. Your implementation must be called ArrayMenu. Much of the code you need can be copied (and lightly modified) from the ArrayBag class provided in the sample code. Note that the Menu should not grow. Once all available slots have been filled in, any attempt to add an option will fail. Make sure your implementation is correct according to all behaviours described in the interface documentation. You must provide the following constructors: - A constructor that takes a title, an array of String (the options), and an integer giving the maximum number of options that this Menu can be given. - A constructor that takes a title and an array of Strings (which are the options for this menu). - A constructor that takes just a title. - A constructor that takes just an array of Strings (which are the options for this menu). - A constructor that takes a title and an int value (which is the maximum number of options for this menu -- attempting to add more options than that will fail). - A constructor that takes just an int value (again, the the maximum number of options). - A no-arguments constructor. If no title is provided, then the menu has no title. If no options are provided, the menu starts with no options. If no maximum size is given, then either: an array of options has been given, and that is the maximum number of options for the array; or no array of options has been given, and a default maximum number of options is given. The title may be nu1l, but the array of starting options can't be. If any constructor is given null where an array of options is expected, it should throw a NullPointerException. If the maximum number of options is less than the number of starting options, then the constructor should throw an IllegalArgumentException with a suitable messageStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started