// This is the test program for Assignment 3, CS 146. The two // classes Apportioner1 and Apportioner2 are identical except // that the heap for Apportioner1 deletes the item with minimal // priority and reinserts it with a new priority, while // the heap for Apportioner2 simply moves it down in the heap. // The "process" function assumes that Apportioner1 and Apportioner2 // both inherit from a base class Apportioner. If this is not // true in your implementation, feel free to make two copies // of this function, whose first arguments are of classes // Apportioner1 in one case and Apportioner2 in the other. // Note that this argument is passed by nonconstant reference. #include "apportion.h" void process(Apportioner &a, int n,string infile, string outfile) { a.readInput(infile); a.apportion(n); a.printLog(n,outfile); a.printApportionment(); a.printComps(); a.clearComps(); a.clear(); } int main() { Apportioner1 a=Apportioner1(3); process(a,10,"test3.txt","temp10.txt"); a=Apportioner1(3); process(a,12,"test3.txt","temp12.txt"); a=Apportioner1(50); process(a,435,"uspop.txt","temp435.txt"); a.printApportionment(); Apportioner2 a2=Apportioner2(3); process(a2,10,"test3.txt","temp10.txt"); a2=Apportioner2(3); process(a2,12,"test3.txt","temp12.txt"); a2=Apportioner2(50); process(a2,435,"uspop.txt","temp435.txt"); return 0; }