2.99 See Answer

Question: Design a class named Pet, which should


Design a class named Pet, which should have the following fields:
- name. The name field holds the name of a pet.
- animal. The animal field holds the type of animal that a pet is. Example values are “Dogâ€, “Catâ€, and “Birdâ€.
- age. The age field holds the pet’s age.
The Pet class should also have the following methods:
- setName. The setName method stores a value in the name field.
- setAnimal. The setAnimal method stores a value in the animal field.
- setAge. The setAge method stores a value in the age field.
- getName. The getName method returns the value of the name field.
- getAnimal. The getAnimal method returns the value of the animal field
- getAge. The getAge method returns the value of the age field.
1. Draw a UML diagram of the class. Be sure to include notation showing each field and method’s access specification and data type. Also include notation showing any method parameters and their data types.
2. Write the Java code for the Pet class.


> If you want to apply styles to all of the nodes in a scene, what selector would you use in a style definition?

> Assume scene is the name of a Scene object, and stylesheet.css is the name of a CSS stylesheet. Write the statement that applies the stylesheet.css stylesheet to scene.

> If you want to place a dotted border around a Label control, which CSS style property would you set?

> How do you determine the file that the user selected with either an open dialog or a save dialog?

> How do you display a save dialog?

> 1. Write a statement that declares a String array initialized with the following strings: “Einsteinâ€, “Newtonâ€, “Copernicusâ€, and “Keplerâ€. 2. Write a loop that displays the contents of each element in the array that you declared in Question

> How do you display an open dialog?

> In what package is the FileChooser class?

> What type of event do menu items generate when selected by the user?

> What class do you use to create a check menu item? How do you cause it to be initially selected?

> How do you create a relationship between radio menu items so only one may be selected at a time?

> What class do you use to create a radio menu item? How do you cause it to be initially selected?

> If you want a control’s text to appear in bold, which CSS style property would you set?

> What class do you use to create a menu item?

> What class do you use to create a menu?

> What class do you use to create a menu bar?

> Write code that creates an ArrayList that can hold String objects. Add the names of three cars to the ArrayList, and then display the contents of the ArrayList.

> Briefly describe each of the following menu system items: 1. Menu bar 2. Menu 3. Menu item 4. Check menu item 5. Radio menu item 6. Submenu 7. Separator bar

> How do you retrieve the text that the user has typed into a TextArea control?

> What is text wrapping? What is line wrapping? How do you enable text wrapping in a TextArea control?

> What is the TextArea’s default number of rows displayed? How do you change the number of rows?

> What is the TextArea’s default number of columns displayed? How do you change the number of columns?

> What is the difference between a TextArea and a TextField?

> How do you get a Slider’s current value?

> Which CSS style property specifies the font for a control’s text?

> What type of event does a Slider generate when its slider knob is moved?

> What Slider methods do you use to perform each of these operations? 1. Establish the spacing of major tick marks. 2. Establish the spacing of minor tick marks. 3. Cause tick marks to be displayed. 4. Cause labels to be displayed.

> The variable names references an integer array with 20 elements. Write a for loop that prints each element of the array.

> What is the difference between an editable ComboBox and an uneditable ComboBox?

> What type of event do ComboBox controls generate when they are clicked?

> How do you retrieve the selected item from a ComboBox?

> In what type of object does the ComboBox control keep its list of items?

> How do you set the orientation of a ListView control?

> What is multiple interval selection mode?

> What is single selection mode?

> How do you retrieve the selected item from a ListView control?

> You haven’t yet learned about the MenuButton control, but you have learned how to convert JavaFX class names to CSS type selectors. What would the type selector name for the MenuButton class be?

> How do you set the size of a ListView?

> Consider the following class declaration: public class Square { private double sideLength; public double getArea () { return sideLength * sideLength; } public double getSideLength () { return sideLength; } } 1. Write a no-arg constructor for this class.

> What type of event do CheckBox controls generate when they are clicked?

> In code, how do you make a CheckBox appear selected?

> How do you determine in code whether a CheckBox is selected?

> What type of event do RadioButton controls generate when they are clicked?

> In code, how do you make a RadioButton appear selected?

> How do you determine in code whether a RadioButton is selected?

> How do you create a mutually exclusive relationship between RadioButton controls?

> In a style definition, what type of selector begins with a # character?

> In the hexadecimal color value #0511FF, the FF value specifies which color component?

> What is the type selector name that corresponds to each of the following JavaFX types? Button TextField Label ImageView

> What type of scene graph node can have children? What type cannot?

> What are the three types of nodes in a scene graph?

> What is a scene graph?

> Is a window the same as a stage, or a scene?

> What is JavaFX?

> What is an event-driven program?

> Describe the three BorderPane constructors.

> What are the names of the regions in a BorderPane container?

> Describe three different techniques discussed in this chapter for writing event handlers.

> How do you retrieve the text that the user has entered into a TextField control?

> Write a method named getName that prompts the user to enter his or her first name, and then returns the user’s input.

> In what package is the TextField class?

> What method do you call to register an event handler with a Button control?

> In what package is the EventHandler interface?

> What is an event handler?

> When the user runs a program in a text-based environment, such as the command line interface, what determines the order in which things happen?

> What is an event? Give an example.

> Once you have created a GridPane container, how do you add a control to a ­specific column and row?

> How do you set the horizontal and vertical spacing in a GridPane container?

> What package is the Insets class in?

> What is the difference between spacing and padding, in regard to layout containers?

> Write a method named timesTen. The method should accept a double argument, and return a double value that is ten times the value of the argument.

> If you want to change the image that an ImageView object is displaying, what method do you call?

> If you want to make sure that an image does not appear stretched after it is resized, what method do you call?

> How do you set the width and height of an ImageView?

> If you want to display an image in a layout container, do you add an Image object, or an ImageView object to the layout container?

> What package contains the Image and ImageView classes?

> How does a command line interface work?

> What package is the Pos enumeration in?

> How do you change the alignment of an HBox container?

> The Scene class is in what package?

> If you want to arrange controls in a grid, with rows and columns, what layout container would you use?

> A program contains the following method definition: public static int cube(int num) { return num * num * num; } Write a statement that passes the value 4 to this method and assigns its return value to a variable named result.

> Account Balance A program that calculates the current balance in a savings account must ask the user for the following: The Starting Balance The total dollar amount of deposits made The total dollar amount of withdrawals made The monthly interest rate On

> What is the general difference between an HBox layout container, and a VBox layout container?

> The program in Code Listing12-1 calls a Stage class’s show method. What does this method do?

> The program in Code Listing12-1 calls a Stage class’s setTitle method. What does this method do?

> What is the purpose of the Application class’s abstract start method?

> What is the purpose of the launch method of the Application class?

> The JavaFX library has an abstract class that is the foundation of a GUI application. What is the name of the class?

> What is a user interface?

> If multiple exceptions can be thrown by code in a try block, how does the JVM know which catch clause it should pass the control of the program to?

> What is the difference between a try block and a catch block?

> How do you retrieve an error message from an exception?

> After the catch block has handled the exception, where does program execution resume?

> Look at the following method header: public static void myMethod(int a, int b, int c) Now look at the following call to myMethod: myMethod(3, 2, 1); When this call executes, what value will be stored in a? What value will be stored in b? What value will

> What is the difference between exceptions that inherit from the Error class and exceptions that inherit from the Exception class?

> Other than the Object class, what is the superclass for all exceptions?

> If an exception is thrown and the program does not handle it, what happens?

> What must you do to a class in order to serialize objects of that class?

> What are the two modes that a random access file may be opened in? Explain the difference between them.

2.99

See Answer