Question
The code below includes a live Infant variable, danasKid. Using statements from the LooseLeaf and Infant classes, make a LooseLeaf object called someBook with name
The code below includes a live Infant variable, danasKid. Using statements from the LooseLeaf and Infant classes, make a LooseLeaf object called someBook with name field filled with danasKid's name, and initial blank page count equal to danasKid's age. For example, if Dana's kid's name is Lena, and Lena is 19 months old, then these would be the values of the name and blankPage instance variables in the someBook object. A hint is provided at the bottom of this page. Enter your code in the box below.
public class LooseLeaf{ // models a looseleaf notebook, with a running count of blank sheets private int blankPages; private String name; // notebook owner public LooseLeaf(String who, int blanks){ blankPages = blanks; name = who; } public int getBlankPages(){ return blankPages;} public String getName(){ return name;} public void setBlankPages(int amount){blankPages = amount;} }
public class Infant{ private String name; private int age; // in months public Infant(String who, int months){ name = who; age = months; } public String getName(){ return name;} public int getAge(){ return age;} public void anotherMonth(){ age = age + 1;} }
need in java and also can explain a little how to do this
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started