subject

For this exercise, you are going to complete the Dog class. The structure has been set up for you, but you will need to complete two constructors (overloaded). The first will take three parameters and assign the values to the instance variables. The method signature should take the name, then age, and finally weight.
The second constructor will only take name then age. For this one, you will assign a value of 0.0 to the dog’s weight.
Once complete, create and print two Dog objects in the DogTester class. The first should use three parameters and the second should only use two parameters.
Sample Output:
Name: Karel
Weight: 15.6
Age: 7
Name: Clover
Weight: 0.0
Age: 9

public class Dog
{
private String name;
private int age;
private double weight;
// Add your constructors here
public String toString(){
return "Name: " + name + "\nWeight: " + weight + "\nAge: " + age;
}
}

public class DogTester
{
public static void main(String[] args)
{
// Start here!
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:30
Write a full class definition for a class named player , and containing the following members: a data member name of type string .a data member score of type int .a member function called setname that accepts a parameter and assigns it to name . the function returns no value.a member function called setscore that accepts a parameter and assigns it to score . the function returns no value.a member function called getname that accepts no parameters and returns the value of name .a member function called getscore that accepts no parameters and returns the value of score .this is what i have, aparently this is wrong: class player{private: string name; int score; public: void player: : setname (string n){name =n; }void player: : setscore (int s){score = s; }string player: : getname (){return name; }int player: : getscore (){return score; }};
Answers: 2
question
Computers and Technology, 23.06.2019 12:00
3. when you right-click a linked spreadsheet object, what commands do you choose to activate the excel features? a. linked worksheet object > edit b. edit data > edit data c. linked spreadsheet > edit d. object > edit data
Answers: 2
question
Computers and Technology, 23.06.2019 15:30
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
What can you prevent issues related to downloading content form the internet
Answers: 1
You know the right answer?
For this exercise, you are going to complete the Dog class. The structure has been set up for you, b...
Questions
question
Chemistry, 21.09.2019 14:30
question
Physics, 21.09.2019 14:30