Question: Objective: Write 2 user defined classes (including a class that contains a main method). These classes should be names Driver and Band. The Driver class
Objective:
Write 2 user defined classes (including a class that contains a "main" method). These classes should be names "Driver" and "Band". The Driver class should contain the main method and will also contain methods to test your other classes.
Specifications:
Driver Class
Create a class called "Driver" with the "main" method. As you write the other classes, you will write methods in the Driver which test the classes. The test methods that you must write are outlined here. All methods in Driver should be public static.
Method name: testBandDefaultConstructor
Input: nothing
Return: nothing
Purpose: Instantiate a Band object and call the objects print method.
Method name: testBandNonDefaultConstructor
Input: int size
Return: nothing
Purpose: Instantiate a Band object with initial size given as an argument to this method and call the objects print method.
Method name: testBandAddMember
Input: nothing
Return: nothing
Purpose: Instantiate a default Band object and add members "Bob", "Susan", "Steve", and "Barb" to the array of band names. Call the objects print method.
Method name: testBandClearNames
Input: nothing
Return: nothing
Purpose: Instantiate a Band object and add members "Bob", "Susan", "Steve", and "Barb" to the array of band names. Call the objects print method. Call the objects clearNames method and then call the objects print method again.
Method name: testBandResize
Input: nothing
Return: nothing
Purpose: Instantiate a Band object of size 2. Add members "Bob" and "Susan". Call the objects print method. Now add "Steve" to the array of band names. Call the objects print method. Now add "Jessica", "Chuck", and "Darlene" to the band and call the objects print method again.
Method name: main
Input: String[] args
Output: void
Purpose: you should call your tester methods here. Remove all lines of code from the main method prior to submitting your code.
Band Class
Create a class called "Band" with the following fields, methods, and constructors.
Field name: names
Accessibility: private
Type: Array of Strings
Purpose: used to store the names of all of the band members.
Field name: memberCount
Accessibility: private
Type: int
Purpose: used to store the number of band members.
Method name: resizeNamesArray
Accessibility: private
Input: int memberCount
Output: void
Purpose: resize the names array so that it has size given as an argument to this function. If growing the array, the new array should contain all of the names from the existing array. If shrinking an array, the new array should contain as many of the names from the existing names array as possible.
Example 1: if names = {"Bob", "Susan", "Steve", "Barb"} and memberCount = 4, the call resizeNamesArray(6) results in names = {"Bob", "Susan", "Steve", "Barb", "", ""} and memberCount = 4. Note the extra spaces in the array containing empty strings.
Example 2: if names = {"Bob", "Susan", "Steve", "Barb"} and memberCount = 4, the call resizeNamesArray(2) results in names = {"Bob", "Susan"} and memberCount = 2. Note that two names have been removed.
Method name: addMember
Accessibility: public
Input: String name
Output: void
Purpose: add a band member to the array of band member names. Don't forget to increment your memberCount. If the names array is not big enough to add the new band member's name, it must be resized. Use the resizeNamesArray method to double the size of the array.
Method name: clearNames
Accessibility: public
Input: nothing
Output: nothing
Purpose: Resets your memberCount to 0.
Method name: print
Accessibility: public
Input: void
Output: void
Purpose: print the list of band members
Example 1: if names = {"Bob", "Susan", "Steve", "Barb","",""} and memberCount = 4, this method should display:
There are 4 band members. Bob Susan Steve Barb Band capacity is 6.
Example 2: if memberCount = 0 and names.length = 6, this method should display:
The are 0 band members. Band capacity is 6.
Default Constructor
Accessibility: public
Input: void
Purpose: initialize the names array and the memberCount. By default, you can assume that a band has 10 or fewer band members. memberCount should be initialized to 0.
Non-default Constructor
Accessibility: public
Input: int size
Purpose: initialize the names array and the memberCount. The names array should be initialized with size given as the argument to the constructor. memberCount should be initialized to 0.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
