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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!