subject

Define a method printAll() for class PetData that prints output as follows with inputs "Fluffy", 5, and 4444. Hint: Make use of the base class' printAll() method. Name: Fluffy, Age: 5, ID: 4444
// Code from file AnimalData. java
public class AnimalData {
private int ageYears;
private String fullName;
public void setName(String givenName) {
fullName = givenName;
}
public void setAge(int numYears) {
ageYears = numYears;
}
// Other parts omitted
public void printAll() {
System. out. print("Name: " + fullName);
System. out. print(", Age: " + ageYears);
}
}
// end
// Code from file PetData. java
public class PetData extends AnimalData {
private int idNum;
public void setID(int petID) {
idNum = petID;
}
// FIXME: Add printAll() member function
/* Your solution goes here */
}
// end
// Code from file BasicDerivedOverride. java
import java. util. Scanner;
public class BasicDerivedOverride {
public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
PetData userPet = new PetData();
String userName;
int userAge;
int userID;
userName = scnr. next();
userAge = scnr. nextInt();
userID = scnr. nextInt();
userPet. setName(userName);
userPet. setAge (userAge);
userPet. setID (userID);
userPet. printAll();
System. out. println("");
}
}
// end

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 18:00, joybeth9591
What can a word user do with the customize ribbon dialog box? check all that apply. minimize the ribbon add a new tab to the ribbon remove a group from a tab add a group to a tab choose which styles appear choose which fonts appear choose tools to appear in a group
Answers: 1
image
Computers and Technology, 24.06.2019 08:20, brinks7994
Which type of entity describes a fundamental business aspect of a database? a. linking b. lookup c. domain d. weak
Answers: 3
image
Computers and Technology, 24.06.2019 09:50, trenrain
Create a string list. 2. use console. readline() to collect values of firstname, lastname, street, city, state, zip, save them to list. 3. write a simple linq statement, call method uppercasewords() to change first letter to uppercase. 4. create a foreach statment to display the information. public static string uppercasewords(string value) { char[] array = value. tochararray(); if (array. length > = 1) { if (char. islower(array[0])) { array[0] = char. toupper(array[0]); } } for (int i = 1; i < array. length; i++) { if (array[i - 1] == ' ') { if (char. islower(array[i])) { array[i] = char. toupper(array[i]); } } } return new string(array);
Answers: 3
image
Computers and Technology, 24.06.2019 17:50, yssbammy
Which of the following best describe how the depth-limited search works. a normal depth-first search is performed but the number of ply/depths is limited. a normal breadth-first search is performed but the number of ply/depths is limited. a normal breadth-first search is performed but values above a specific value will be ignored. a normal depth-first search is performed but values above a specific value will be ignored.
Answers: 1
You know the right answer?
Define a method printAll() for class PetData that prints output as follows with inputs "Fluffy", 5,...

Questions in other subjects:

Konu
Mathematics, 29.08.2021 07:40
Konu
Mathematics, 29.08.2021 07:40