subject

Define a method printall() for class petdata that prints output as follows. hint: make use of the base class' printall() method.

name: fluffy, age: 5, id:


// code from file animaldata. java
public class animaldata {
private int ageyears;
private string fullname;

public void setname(string givenname) {
fullname = givenname;
return;
}

public void setage(int numyears) {
ageyears = numyears;
return;
}

// other parts omitted

public void printall() {
system. out. print("name: " + fullname);
system. out. print(", age: " + ageyears);
return;
}
}
// end

// code from file petdata. java
public class petdata extends animaldata {
private int idnum;

public void setid(int petid) {
idnum = petid;
return;
}

// fixme: add printall() member function

/* your solution goes here */

}
// end

// code from file basicderivedoverride. java
public class basicderivedoverride {
public static void main (string [] args) {
petdata userpet = new petdata();

userpet. setname("fluffy");
userpet. setage (5);
userpet. setid ();
userpet. printall();
system. out. println("");

return;
}
}
// end

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:30
Data for which there is temporarily no room in ram is diverted to where on your computer? question 9 options: a) the paging file on the hard drive b) the system file on the hard drive c) the memory file on the hard drive d) the cpu cache
Answers: 2
question
Computers and Technology, 22.06.2019 18:00
Write a method named addall that could be placed inside the hashintset class. this method accepts another hashintset as a parameter and adds all elements from that set into the current set, if they are not already present. for example, if a set s1 contains [1, 2, 3] and another set s2 contains [1, 7, 3, 9], the call of s1.addall(s2); would change s1 to store [1, 2, 3, 7, 9] in some order. you are allowed to call methods on your set and/or the other set. do not modify the set passed in. this method should run in o(n) time where n is the number of elements in the parameter set passed in.
Answers: 2
question
Computers and Technology, 22.06.2019 21:00
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings starting from index 0. for each match, add one point to userscore. upon a mismatch, exit the loop using a break statement. assume simonpattern and userpattern are always the same length. ex: the following patterns yield a userscore of 4: simonpattern: rrgbryybgy userpattern: rrgbbrybgy
Answers: 2
question
Computers and Technology, 23.06.2019 07:30
To check spelling errors in a document, the word application uses the to determine appropriate spelling. internet built-in dictionary user-defined words other text in the document
Answers: 2
You know the right answer?
Define a method printall() for class petdata that prints output as follows. hint: make use of the b...
Questions
question
Mathematics, 28.04.2021 20:00
question
Mathematics, 28.04.2021 20:00
question
Mathematics, 28.04.2021 20:00
question
Mathematics, 28.04.2021 20:00
question
Mathematics, 28.04.2021 20:00
Questions on the website: 13722363