Build the ProjectRunner Class Create the Project Runner class the same way you created the other...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Build the ProjectRunner Class Create the Project Runner class the same way you created the other two classes. Fill out the fields and methods to match the class diagram. (You don't need to provide the default constructor for this class) <<Java Class>> ProjectRunner project1 ProjectRunner() main(String:void Implement ProjectRunner's main method There is an example of using a main method in the HokieClass example from the first day of class. Inside your main(String[] args) method for this project, create a new instance of the DisplayCollection class. Then, create a new Shapewindow instance, passing the itemBag of your Display Collection instance into the constructor. 2. Create buttons In this section we will create and implement buttons. The example zip file above may be a helpful reference Create the Quit Button for your Window Now we're going to add the Quit Button. In the Shape Window constructor: 1. Instantiate the quitButton field by using the Button (String title) constructor. Give it the String "Quit" for its name parameter. 2. Use the onClick(Object object, String methodName) method to set what method will be called when the quit Button is pressed. The arguments should be this for the object parameter and “clickedQuit" for methodName. This tells the quitButton to call your clickedQuit (Button button) method when it is clicked. 3. Use addButton (Button button, WindowSide side) on the window field to make the quitButton appear in the window. The quitButton should be on WindowSide.NORTH. Try running your project again. You should now see a button on the upper side of your Window which says "Quit." Since we haven't implemented the clicked Quit (Button button) method yet, clicking the button will not work yet. Implement your Quit Button Implement the clickedQuit (Button button) method by calling System.exit(int status). This method expects an integer parameter. Use zero as the parameter to indicate that no errors occurred. The quitButton should now close the window when clicked. Create the Choose Button for your Window In your constructor, initialize the chooseButton field with the title "Choose" the same way you initialized quitButton. Use the onClick(Object object, String methodName) method to specify that "clicked Choose" is called when the button is clicked. Add the chooseButton to the window on the WindowSide. SOUTH. The choose button won't work yet, but you should now see it in your window when you run your program. 3. Fill a Bag DisplayCollection's constructor Make a new Random object variable named random and initialize it by using the default constructor of the Random class. You will use this variable to randomly generate numbers. Use the nextInt(int upperBound) method to randomly generate a number. Generate a number from 5 to 15 (inclusive) which will determine your bag's size. Save that size in a variable which will be used next. Look at the API for Random to see how to use the nextInt(int upperBound) method. The code below gives you a starting point to work with. Random random = new Random(); int count = random.nextInt(x) + y; Build a for loop that adds new strings to the itemBag field based on the random number you generated. Randomly select one of the strings in the STRINGS array to add to the itemBag. Place each string into the itemBag by calling the add(T item) method. Build the ProjectRunner Class Create the Project Runner class the same way you created the other two classes. Fill out the fields and methods to match the class diagram. (You don't need to provide the default constructor for this class) <<Java Class>> ProjectRunner project1 ProjectRunner() main(String:void Implement ProjectRunner's main method There is an example of using a main method in the HokieClass example from the first day of class. Inside your main(String[] args) method for this project, create a new instance of the DisplayCollection class. Then, create a new Shapewindow instance, passing the itemBag of your Display Collection instance into the constructor. 2. Create buttons In this section we will create and implement buttons. The example zip file above may be a helpful reference Create the Quit Button for your Window Now we're going to add the Quit Button. In the Shape Window constructor: 1. Instantiate the quitButton field by using the Button (String title) constructor. Give it the String "Quit" for its name parameter. 2. Use the onClick(Object object, String methodName) method to set what method will be called when the quit Button is pressed. The arguments should be this for the object parameter and “clickedQuit" for methodName. This tells the quitButton to call your clickedQuit (Button button) method when it is clicked. 3. Use addButton (Button button, WindowSide side) on the window field to make the quitButton appear in the window. The quitButton should be on WindowSide.NORTH. Try running your project again. You should now see a button on the upper side of your Window which says "Quit." Since we haven't implemented the clicked Quit (Button button) method yet, clicking the button will not work yet. Implement your Quit Button Implement the clickedQuit (Button button) method by calling System.exit(int status). This method expects an integer parameter. Use zero as the parameter to indicate that no errors occurred. The quitButton should now close the window when clicked. Create the Choose Button for your Window In your constructor, initialize the chooseButton field with the title "Choose" the same way you initialized quitButton. Use the onClick(Object object, String methodName) method to specify that "clicked Choose" is called when the button is clicked. Add the chooseButton to the window on the WindowSide. SOUTH. The choose button won't work yet, but you should now see it in your window when you run your program. 3. Fill a Bag DisplayCollection's constructor Make a new Random object variable named random and initialize it by using the default constructor of the Random class. You will use this variable to randomly generate numbers. Use the nextInt(int upperBound) method to randomly generate a number. Generate a number from 5 to 15 (inclusive) which will determine your bag's size. Save that size in a variable which will be used next. Look at the API for Random to see how to use the nextInt(int upperBound) method. The code below gives you a starting point to work with. Random random = new Random(); int count = random.nextInt(x) + y; Build a for loop that adds new strings to the itemBag field based on the random number you generated. Randomly select one of the strings in the STRINGS array to add to the itemBag. Place each string into the itemBag by calling the add(T item) method.
Expert Answer:
Answer rating: 100% (QA)
Below is the Java implementation of the projectrunner class according to the spec... View the full answer
Related Book For
Systems analysis and design
ISBN: 978-0136089162
8th Edition
Authors: kenneth e. kendall, julie e. kendall
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Question. Consider the inverse demand function P=20-Q and the inverse supply function P=2+Q. Find (a) equilibrium price P* and Q*, (b) consumers surplus (CS), producers surplus (PS) and the total...
-
Marshall Devices manufactures metal products and uses activity-based costing to allocate overhead costs to customer orders for pricing purposes. Many customer orders are won through competitive...
-
Evaluate the following integrals. J x 16x dx
-
Abbott Industries is a well-known supplier of pharmaceuticals worldwide. Founded by Dr. Wallace Abbott, the company was incorporated in 1900 after he had been developing and making pharmaceuticals...
-
The vapor leaving the top of a distillation column goes to a condenser in which either total or partial condensation takes place. If a total condenser is used, a portion of the condensate is returned...
-
4. Write as a single power, then evaluate. Express answers in rational form. a) V55 -16 b) c) 284 7 18 (9) d) 2
-
Toms, Inc., produces various Mexican food products and sells them to Western Foods, a chain of grocery stores located in Texas and New Mexico. Toms, Inc., makes two salsa products: Western Foods...
-
Daniel, an electrical engineer, resigned from Tenaga Nasional Berhad to start his own trading in electrical goods. He required the following assets: Furniture and fittings A computer A cash register...
-
Translate the following symbolic statements in words. 1)p ~q 2)s~r 3)q ~s Translate the following verbal statements into symbols. 4)Ground moves affect Flying-type Pokmonif some Pokmondo not have a...
-
A company's product requires 3 ponds of direct materials at $21.60 per pund and 2 direct labor hours at $48.60 per hour. The company uses an overhead rate of $41.80 per direct labor hour to assign...
-
Why is medical record documentation an important part of the provider's ability to provide quality care? Explain.
-
Dino Marty is the office manager for Fix It Physical Therapy Associates. Dino is responsible for all the accounts receivable that pertains to the office practice. The standard billing rate is $200...
-
There are two ways to have 30 cents using six coins, either six nickels or one quarter and five pennies. For each of thecombinations of coins given, find the minimum n such that n (middle value coin)...
-
Now consider another language L, of strings having exactly double a and having one number of bs defined over = {a, b}, then its regular expression maybe?
-
After looking at the resources, explain what a spirit image is. Why might looking at a god and/or a human in terms of their spirit be helpful if you want to eliminate some of the divisions between...
-
Develop a check digit system for the part numbers in Problem 10 using the Luhn formula.
-
What is scrum?
-
Create a document type definition for Problem 11.
-
A gene is a segment of DNA that contains the information to produce a functional product. The functional product of most genes is a. DNA. b. mRNA. c. a polypeptide. d. none of the above.
-
Which of the following is not a constituent of a cells proteome? a. An enzyme b. A cytoskeletal protein c. A transport protein in the plasma membrane d. An mRNA
-
The function of the genetic code is to a. promote transcription. b. specify the amino acids within a polypeptide. c. alter the sequence of DNA. d. do none of the above.
Study smarter with the SolutionInn App