Aggregation class,
Aggregation Sample Class In order to gain practical knowledge of aggregation and to practice deep copying of the field objects we will implement a class called Aggregation Sample . The class must have } fields : fraction Field of type Fraction ( class from the first problem ; arrayField - array of integers - type int double Field of type double* The class does not really have any functionality and it's main purpose is to give You a hands - on review of the aggregation concept . Class has a very limited number of methods . all of them are standard methods that you would expect to have in any regular class . 1 . Non- argument constructor that sets a. fraction Field to fraction ! .b . array field to an array of size ? filled with Us. and C. double Field to O 2. Constructor that takes a fraction ( as an object ) . an array , and a double as parameters and sets all ; fields to the given Values . Make sure to create DEEP COPIES Of all non - primitive parameters when setting the new object fields* 3. Copy constructor . Make sure to create DEEP COPIES Of all non - primitive fields when setting the new object fields . 4 . Three accessor methods for all ] fields . Make sure to create DEEP COPIES Of all non - primitive fields and return a reference to a copy not to the original field. 5 . Three mutator methods for all 3 fields . Make sure to create DEEP COPIES Of all toll - primitive parameters when changing the value of the fields . 5. to String( ) method that creates and returns a string containing all ? fields in text format . like*Fraction. I and 1/24; ^`. (1, 0,]]. Double: 3. 4}*^ LEE tests provided in Aggregation Demo. Jara . Please make sure all tests Inn and produce EXPECTEd results .* TO Change this License HeadEz , Change LICENSE HEATERS IN PROJECT PROPERTIES . " To Change This template FILE .) . . Choose TOOLE | Templates* " and open the FELLLate is the Editor . Package aggregationdemo * * RanchOF AV` public Class Aggregation Demo !" " BEorom args the command Line BEJUTENE = Public static Hold mall ( String!l args ! !` Aggregationsample first = NEW Aggregationsample ! ! !` WILLITBE . COSTRING (I . ETHE IS ! " FRACTION OF AFTER : 10, 0. 01 : Double : 0 . 0'] ]] SYSTEM . OUT . PRINTIn ! ' Test I BaggEd " ) !` Evatem . Out . Print In / First . toString (1 1; ! !' Output "ELECTION: D . HITOY : [O. O. JI , DOUBLE : O . O ") ELSE System . out . print In !"' Test I Foil=] " ) ;` Int ! ! $ = 1 1 , 2 . 3. 47 :` ELECTION I = VIEW Fraction1 1 , 21 : AggregationSample second = new AggregationSample 1 1 , 6 , 5 . 01 : if ( second . toString ( i . EJUS IS ! ' ELECTION ! !/}. HILEY : [1, 2. 3. 41. DOUBLE : S . E ' ]! SYSTEM . OUT . Print In ! "' TEST 2 PassEd " ! !` SYSTEM . Out . Print In / second . ToString lil ! ! !| QUEFUE ' EZACTION ! 1/ }; FIZZY : [1, 2 , 3, 41; DOUBLE : 5 . 6*^ ELSE System . Out . Print In ! " Test ? Failed") ; `` these Changes TO OILFinal Objects That not Change the " second" OBJECT $ 101 = 10 0:` I . GETNumerator ( 5 1 :` If ( SECOND . COSTTING ! ! . EITHE IS ! ' ELECTION : 1/ 2. AFTER : [1 . 2. 3. 41 : DOUBLE . S. E ' ] ] SYSTEM . OUT . PRINTIN !' TEST } [ABBEN ' ! !` System . Out . print In / second . ToString ! ! ! ! ! !' Output ' Fraction! 1/2: LIZZY : [ 1. 2 . 3. 41 : DOUBLE : 5 . E " Else System . Out . print la !' Test ] ExilEs") ; int ! ! ! = second . getarray ! ! !` ` [ 0] = 300;! !' CHANTE THE BILLY IS MAKE SURE THE BODY Of the Field was returned Fraction = Second . getFraction! ! !` IZ . SETHUMETaLOT 131 ; ! !' CHANTE THE TRACTION TO THERE QUITE THE BODY OF THE FIELD HAS RESULTED!SYSTEM . OUT . CLINTINISTEST = FEESEd!") !` System . Out . print in / second . tostring ! ! ! ! ! ! QUEFUE " FIOFFLET : 1/ }. BITOF : [1. 2. 1. 41. Double : 5 .`^ FIVE System . Out - PrintIn ! " Test ] Failed" ] :` ! ! THESE CHANGES TO CRITICAL OBJECTS QUIET RIOT CHETTE LOE " second" object $ 101 - 100 ; I . BETHUNE CUTOF 1 51 : $ Flatcond . COString !) . Equals !"' FIREFLON'T 1/2+ ATTOY : [ 1 , 2. 1. 41 : DOUBLE : 5. 6' 1 ) SYSTEM IT _ DUE . PIINTINY TEST } BESTEd "] :` SYSTEM . Out . print In / second . Tostringlil: / / OUTPUT " ELECTION: 1/ 2, RELAY : [1.2. 3. 11 . DOUBLE : 5 . 6!'` cleE Eratem . OUT . DRIVEL ! " Test. & Called ") ; LoE [ ] 6 = Second . GELATTAY ! ! !` 6101 - 300;!' "' change the aI_AY TO Take SUCE THE OFF' Of The FIELD was returned Fraction = second . S= [ Fraction ! ! !` IZ . actilunc rator 131 ! ! !' change the Fraction TO THEE JUICE THE COPY OF the field HAS TOturnEd! Tout LE * = SECOND . JELDOUBLE ! ! !` I f laceand . toString !) . equals !' "' Fraction; I'}; ALLOY : [ 1 . 2. 3. 11 : Double : 5 . 6"' ! !` System . Out . print la! " Test { DoggEd "'! !` SYSTEM . OUT . printla / second . LastFlag! ! ! ! " '' OUTEU= HUGE LE BY DEFOE= " ELaction ; I/ } . PLAY : [1 , 2 , 3, ST . DOUBT = = 5 . 0 "^ = IZE SYSTEM . OUT . PILOTla ! " TEST 4 FELLEQUITY : FLEET . Setarcarini !` b/01 - 0: / / change the original array to make sure The deep For; was Rode* ILLET . GETFRACTION|[ ] ! !` EZ - BETHUNETOTOT IT! ! ! !' CHENTE ORIGINAL FIRSTLOT TO MAKE SURE the DEED FORY WAS Made FLEET . BET Double 133 . 31 !` FIFirst . COString (1 . Equals !'" Fractions . And !/}; AFTER: 1700 , 2 . 3. 41 : Doable : 31. 101 ) SYSTEM . Out . PrintIN ! " Test 5 BETTER " ] :` SYSTEM . OUT . PRINTIN KIL TEE . TOSTRICT! ! ! ! ! !" OUTPUT MUST be a` BEFORE " ELECTION! !/ }, AILEY ; [LIZ , 3, 41 . Double . S. En [ Else Eyatem . Out . printLa ! " TEST. 5 Called "! `