Question
Create test class to test the methods ------------------------------------------------------------------------ public class Institute { private String name; private Person arp[]; private int nb; Institute(String name) { this.name
Create test class to test the methods
------------------------------------------------------------------------
public class Institute { private String name; private Person arp[]; private int nb; Institute(String name) { this.name = name; arp = new Person[2000]; nb = 0; } public void addPrson(Person p) { if (nb >= arp.length) return; if (p instanceof Graduate) arp[nb] = new Graduate((Graduate) p); else arp[nb] = new Undergraduate((Undergraduate) p); nb++; } public int countUnder(double s) { int count = 0; for (int i = 0; i < nb; i++) if (arp[i] instanceof Undergraduate) if (arp[i].calculateScore() >= s) count++; return count; } public Graduate[] getGraduate(int n) { Graduate[] g = new Graduate[nb]; int j = 0; for (int i = 0; i < nb; i++) { if (arp[i] instanceof Graduate) { Graduate x = (Graduate) arp[i]; if (x.getNbPapers() > n) { g[j] = x; j++; } } } return g; } }
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