Question
Need help with the JAVA code for this question @Override public Object grab() { // TODO Auto-generated method stub return null; } @Override public int
Need help with the JAVA code for this question
@Override
public Object grab() {
// TODO Auto-generated method stub
return null;
}
@Override
public int count(Object target) {
// TODO Auto-generated method stub
return 0;
}
@Override
public int removeAll(Object target) {
// TODO Auto-generated method stub
return 0;
}
@Override
public void clear() {
// TODO Auto-generated method stub
}
}
Java Driver for the program
Use the following driver program to test your Bag implementation (feel free to add your own code for sufficient testing):
public class BagDriver {
public static void main(String[] args){
Bag myBag = new Bag(10);
FamousPerson p1, p2, p3;
p1 = new FamousPerson("John", "McEnroe", 1980, "Tennis star.");
p2 = new FamousPerson("Herman", "Hollerith", 1860, "American scientist.");
p3 = new FamousPerson("John", "McEnroe", 2017, "Tennis announcer.");
System.out.println(myBag);
myBag.add(p1);
myBag.add(p2);
myBag.add(p3);
System.out.println(myBag);
System.out.println(myBag.grab());
System.out.println(myBag.count(p1));
System.out.println(myBag.removeAll(p1));
System.out.println(myBag); myBag.clear();
System.out.println(myBag);
}
}
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