subject

Write and test a Java project that satisfies the following requirements:Create a class definition file and a test driver file as follows:Create a class to hold and manipulate data for a Pet for a pet adoption service. The class will have these fields:pet type (a String)pet name (a String),cost to adopt(a double)Write the following methods for the Pet class:A default (no-args) constructorA constructor with parameter values for all the fieldA toString( ) method that uses all the fields. An equals( ) method that is based on both the pet type and pet nameA compareTo( ) method that is based only on the cost to adoptOnce the Pet class compiles write a Driver class with the main( ) method. The main( ) method will declare three Pet reference variables. It will then create the Pet objects reading the data from the file named rescue. txt. The file is comma delimited. (use the StringTokenizer class- example is posted on Canvas and was assigned for Activity 5). Use the data read in to send to the Pet constructor. NOTE WELL: The StringTokenizer method nextToken( ) returns a String. To send the cost valueto the Pet constructor you must convert this field to a double. TO do this here is an example: strCost = stok. nextToken( ); doubleCost = Double. parseDouble(strCost);After the objects have been created print the state of the three Pet objects using the toString( ) method. Test the equals( ) method using the first Pet object and the second Pet object. Test the compareTo( ) method by using the first Pet object and the third Pet object. Print the results of these two tests. Be sure your print statements are clearly labeled so it is obvious what was tested.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:00
Our primary purpouse as electricians is to do wich of the following core concepts? a: install electrical components in a way they can be upgraded b: install electrical equiptment in a way that reduces heat c: install electrical systems in a safe manner d: only b and c
Answers: 1
question
Computers and Technology, 22.06.2019 18:00
Budgets you to do all of the following expect a) send frivolously b) avoid over spending c) gain financial independence d) examine your priorities and goals
Answers: 2
question
Computers and Technology, 23.06.2019 16:00
Kenny works with an it company. his company is about to launch new software in the market. he has to ensure that this new software is functional and meets all of the quality standards set up at the planning stage. which job profile is kenny likely to have? kenny is likely to have the job profile of a blank .
Answers: 2
question
Computers and Technology, 23.06.2019 18:50
Ais a picture icon that is a direct link to a file or folder
Answers: 1
You know the right answer?
Write and test a Java project that satisfies the following requirements:Create a class definition fi...
Questions
question
Mathematics, 19.10.2021 01:30
question
Mathematics, 19.10.2021 01:30
question
English, 19.10.2021 01:30
Questions on the website: 13722363