Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Notice that the code Netbeans is going to automatically generate for you is shown in the Preview window. Make sure your dialog box looks like

image text in transcribed
Notice that the code Netbeans is going to automatically generate for you is shown in the Preview window. Make sure your dialog box looks like the one above then click OK. Note: you may wonder why you'd bother to fill out this dialog box when you could have just typed private int un burgers - Oathe top of your class Butlook closely at what NetBeans has done for you. It added two complete new public methods (the gutter and the setter) that allow other code to find out and change the value of numHamburgers. It put the field in the proper place at the top of the file. It added all the appropriate curly braces, and the Javadoc comments. That is a lot of typing avoided, and probably lots of errors avoided too. This code isn't perfect, but it's a really good start 7) Modify the set.Numamburgers) method so that if the parameter passed in is less than zen, an error is printed out and the field value is not changed This would be a good time to pause for a moment and review what just happened. Note how the getters and setters use the parameters that were passed in to set the values of the fields for this class. Later, when we create objects of this class, you'll see how this capability is used 8) Add three more private ficlds to this class intumCheeseburgers, int numVeggieburgers, and int num.Sedas, following the same process, and initializing cach toe. Note that the code is added wherever your cursor is in the file when you clicked the Insert Code command so if you want all your field definitions grouped together at the beginning of your code you'll have to manually move things around 9) Repeat step 7 forset NumCheeseburgers ().setNumVeggieburgers (), and set NumSodas (). 10) Add a private boolean ficld called order TOGO to the class, and initialize it to false. Notice that when Netbeans generates a getter for this field, it calls it isorderTOGO (), which makes the method more readable, and obvious that it is going to return a boolean 11) Add one more field to this class: a private integer for order Num. Initialize it to a positive number of your choosing 12) If necessary, organize the components of your class so they are in the standard onder all the fields at the top and the getters and setters below them 13) Finally, add a constructor to this class. Right click in the class (below the fields, but above the first getter setter method) and choose Insert Code ... then select Constructor... from the popup menu. This time there is no dialog box, but a default constructor is added to the top of the class 14) Modify the constructor so that it takes six parameters, one cach for the number of Hamburgers, Cheeseburgers, Veggieburgers and sodas to put in the food order, and one boolean parameter that specifies if the order is for takeout, and one for the order number. Inside the constructor, set cach field to the appropriate parameter ITSC 1213 Lab 4 15) Finally, add a toString() method to your class. This method is something that you usually add to a new class that specifies how to print out information about the object (so that if the object is passed as the parameter to a System.out.printint call good information is displayed). To do this, right click at the bottom of the class, after the last gettersetter, and select Insert Code... and then select toString from the popup window. What you should see is a dialog pop up that asks you which fields to print out: Notice that the code Netbeans is going to automatically generate for you is shown in the Preview window. Make sure your dialog box looks like the one above then click OK. Note: you may wonder why you'd bother to fill out this dialog box when you could have just typed private int un burgers - Oathe top of your class Butlook closely at what NetBeans has done for you. It added two complete new public methods (the gutter and the setter) that allow other code to find out and change the value of numHamburgers. It put the field in the proper place at the top of the file. It added all the appropriate curly braces, and the Javadoc comments. That is a lot of typing avoided, and probably lots of errors avoided too. This code isn't perfect, but it's a really good start 7) Modify the set.Numamburgers) method so that if the parameter passed in is less than zen, an error is printed out and the field value is not changed This would be a good time to pause for a moment and review what just happened. Note how the getters and setters use the parameters that were passed in to set the values of the fields for this class. Later, when we create objects of this class, you'll see how this capability is used 8) Add three more private ficlds to this class intumCheeseburgers, int numVeggieburgers, and int num.Sedas, following the same process, and initializing cach toe. Note that the code is added wherever your cursor is in the file when you clicked the Insert Code command so if you want all your field definitions grouped together at the beginning of your code you'll have to manually move things around 9) Repeat step 7 forset NumCheeseburgers ().setNumVeggieburgers (), and set NumSodas (). 10) Add a private boolean ficld called order TOGO to the class, and initialize it to false. Notice that when Netbeans generates a getter for this field, it calls it isorderTOGO (), which makes the method more readable, and obvious that it is going to return a boolean 11) Add one more field to this class: a private integer for order Num. Initialize it to a positive number of your choosing 12) If necessary, organize the components of your class so they are in the standard onder all the fields at the top and the getters and setters below them 13) Finally, add a constructor to this class. Right click in the class (below the fields, but above the first getter setter method) and choose Insert Code ... then select Constructor... from the popup menu. This time there is no dialog box, but a default constructor is added to the top of the class 14) Modify the constructor so that it takes six parameters, one cach for the number of Hamburgers, Cheeseburgers, Veggieburgers and sodas to put in the food order, and one boolean parameter that specifies if the order is for takeout, and one for the order number. Inside the constructor, set cach field to the appropriate parameter ITSC 1213 Lab 4 15) Finally, add a toString() method to your class. This method is something that you usually add to a new class that specifies how to print out information about the object (so that if the object is passed as the parameter to a System.out.printint call good information is displayed). To do this, right click at the bottom of the class, after the last gettersetter, and select Insert Code... and then select toString from the popup window. What you should see is a dialog pop up that asks you which fields to print out

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 8th International Symposium Sstd 2003 Santorini Island Greece July 2003 Proceedings Lncs 2750

Authors: Thanasis Hadzilacos ,Yannis Manolopoulos ,John F. Roddick ,Yannis Theodoridis

2003rd Edition

3540405356, 978-3540405351

More Books

Students also viewed these Databases questions

Question

Q. Who would you generally credit as being your mentors in life?

Answered: 1 week ago

Question

What is operatiing system?

Answered: 1 week ago

Question

How autonomous should the target be left after the merger deal?

Answered: 1 week ago