Question: Getting Started: Basic NetBeans Java Application Project Information Create a new NetBeans Java application project and name it pp1_your-clid-or-ulid. As part of the project, NetBeans

Getting Started: Basic NetBeans Java Application Project Information Create a new NetBeans Java application project and name it pp1_your-clid-or-ulid. As part of the project, NetBeans will create package pp1_your-clid-or-ulid and class Pp1_ your-clid-or-ulid (this in file Pp1_ your-clid-or-ulid.java). Under the Projects tab on the left, right click on the package and select New, Java Class. Name this class an appropriate name for a class that will keep track of pet information at a small animal veterinary clinic and click Finish. This will create the class as you named it in a ".java" based on the name you used and will be located within package pp1_your-clid-or-ulid. (continued on next page) CMPS 260 Fall 2017 Programming Project #1 2 Step One: Code the Pet Information Class The pet information class must contain data members (fields) that maintain the state information about a pet for for the records of a veterinary clinic. I. e. the pet information class the name of the pet // must not be a zero length string if the pet is a dog or a cat the breed of the pet // must not be a zero length string the age of the pet // must be a value > 0 and may contain a fraction the weight of the pet // in pounds or kilos, may contain a fraction, must be > 0 the name of the owner of the pet // must not be a zero length string Pet Information Class Design Requirements All class data members (fields) must be private. All class data members (fields) must be initialized to default or neutral values as appropriate. For example: -na- or "unknown" could be used for strings, false or true for Booleans, and a negative number or zero for numeric types. All class data members (fields) must have getter (accessor) methods and setter (mutator or manipulator) methods. The class must have a default constructor and a parametrized constructor. A call to a constructor with operator new must result in all class data members (fields) being initialized. Class data members (fields) may never contain invalid values, except those values used as initial values when an object of the class is created with the operator new. The class may not include any input or output. Data may be passed in as a parameter to a method or constructor or returned by a method. Class data members (fields) must not depend on external to the object storage. I. e. a class data member can be initialized by a value passed to a constructor or a setter, but all getters must be NOT be passed any values and must return the values stored in the class data members (fields) without being dependent on any data stored outside of the object. No method of the class may be static. CMPS 260 Fall 2017 Programming Project #1 3 Step Two: Test the Pet Information Class In the main method of class Pp1_your-id, make objects of the pet information class by calling both constructors and use the reference variables to call all methods. When you are satisfied that your class words correctly, erase the testing code (just the code in main, not the code in your class!). Step Three: Write the Demonstration Code in the main Method of Class P p 1_ your-clid-or-ulid Demonstrate that your pet information class works correctly as a data type as follows. In class Pp1_your-id, create static methods that receives an array of type pet information class and collects pet information from the user and stores this information in the pet class objects referenced by all elements in the array. receives an array of type pet information class and lists the information about each pet contained in the array to the terminal screen. receives an array of type pet information class and verifies the weight of each pet in the array with the user. The user may elect to enter a new weight for any of the pets. receives an array of type pet information class and returns the average age of all dogs stored in the array receives an array of type pet information class and returns the average age of all cats stored in the array receives an array of type pet information class and returns the average weight of all dogs stored in the array receives an array of type pet information class and returns the average weight of all cats stored in the array In the main method, create an array of 5 elements with the pet information class as the data type. calls each of the static methods in order to collect information about 5 pets, list all information stored about the all pets check and if necessary correct the weights of all pets stored in the array receive and output the average weights and the average age of all dogs and cats stored in the array. CMPS 260 Fall 2017 Programming Project #1 4 Extra Points (10 points max) The pet information class includes a method toString based on the following header. toString must return a string summary that includes all the state information (data stored in the class fields) and must not receive any any values passed as parameters. toString must be used in the the class Pp1_your-id to produce output. public String toString() Tips: The array elements must be individually initialized by operator new. This can be done in method main or in another method, such as the method that collects the pet data. A Scanner class object may be created in method main and passed to appropriate methods as required or a Scanner class object may be created in a method that needs user input. The average weights and ages can be calculated by two or four methods. For example, the average weight of cats can be returned by one method and the average weight of dogs can be returned by another. However, the average weight of either dogs or cats can be returned by a single method that receives as a second parameter the type of pet to average. Watch out for numeric to a line of string input (nextInt() or nextDouble() to nextLine() calls in class Scanner. This requires a "dummy read" in between the read of the number and the read of the whole line. Example: If "input" is the Scanner reference variable: double = input.nextDouble(); input.nextLine(); String s = input.nextLine(); (continued on next page) CMPS 260 Fall 2017 Programming Project #1 5 Additional Requirements (a) Identifiers must be descriptive, i. e. must self document. The only exception granted is in the case of a for variable, that is a variable created as a simple counter as in the control variable in a for loop statement. (b) Indention of all code blocks (compound statements, anything in braces), including single statements following selection or while statements, is required. NetBeans will do this fairly automatically as you type if your syntax is correct. ALT-SHIFT-F will re-format a whole file (if your syntax is correct), which can help make it easier to debug logic in functions, loops, ifs and switches.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!