ProgrammingPrinciples11.2THEGAMEOFLIFEExercises1.2DeterminebyhandcalculationwhatwillhappentoeachoftheconfigurationsshowninFigure1.1overthecourseoffivegenerations.[Suggestion:SetuptheLifeconfigurationonacheckerboard.Useonecolorofcheckersforlivingcellsinthecurrentgenerationandasecondcolortomarkthosethatwillbebornordieinthenextgeneration.]Answer(a)Figureremainsstable.(b)(c)(d)Figureisstable.12Chapter1_ProgrammingPrinciples(e)(f)Figurerepeatsitself.(g)(h)(i)Figurerepeatsitself.(j)(k)(l)Figurerepeatsitself.Section1.3_ProgrammingStyle31.3PROGRAMMINGSTYLEExercises1.3E1.Whatclasseswouldyoudefineinimplementingthefollowingprojects?Whatmethodswouldyourclassespossess?(a)Aprogramtostoretelephonenumbers.AnswerTheprogramcoulduseclassescalledPhone_bookandPerson.ThemethodsforaPhone_bookobjectwouldincludelook_up_name,add_person,remove_person.ThemethodsforaPersonobjectwouldincludeLook_up_number.Additionalmethodstoinitializeandprintobjectsofbothclasseswouldalsobeuseful.(b)AprogramtoplayMonopoly.AnswerTheprogramcoulduseclassescalledGame_board,Property,Bank,Player,andDice.Inadditiontoinitializationandprintingmethodsforallclasses,thefollowingmethodswouldbeuseful.TheclassGame_boardneedsmethodsnext_cardandoperate_jail.TheclassPropertyneedsmethodschange_owner,look_up_owner,rent,build,mortgage,andunmortgage.TheclassBankneedsmethodspayandcollect.TheclassPlayerneedsmethodsroll_dice,move_location,buy_propertyandpay_rent.TheclassDiceneedsamethodroll.(c)Aprogramtoplaytic-tac-toe.AnswerTheprogramcoulduseclassescalledGame_boardandSquare.Theclassesneedinitializationandprintingmethods.TheclassGame_boardwouldalsoneedmethodsmake_moveandis_game_over.TheclassSquarewouldneedmethodsis_occupied,occupied_by,andoccupy.(d)Aprogramtomodelthebuildupofqueuesofcarswaitingatabusyintersectionwithatrafficlight.AnswerTheprogramcoulduseclassesCar,Traffic_light,andQueue.Theclasseswouldallneedinitializationandprintingmethods.TheclassTraffic_lightwouldneedadditionalmethodschange_statusandstatus.TheclassQueuewouldneedadditionalmethodsadd_carandremove_car.E2.Rewritethefollowingclassdefinition,whichissupposedtomodeladeckofplayingcards,sothatitconformstoourprinciplesofstyle.classa{//adeckofcardsintX;thingY1[52];/*Xisthelocationofthetopcardinthedeck.Y1liststhecards.*/public:a();voidShuffle();//Shufflerandomlyarrangesthecards.thingd();//dealsthetopcardoffthedeck};AnswerclassCard_deck{Carddeck[52];inttop_card;public:Card_deck();voidShuffle();Carddeal();};4Chapter1_ProgrammingPrinciplesE3.Giventhedeclarationsinta[n][n],i,j;wherenisaconstant,determinewhatthefollowingstatementdoes,andrewritethestatementtoaccomplishthesameeffectinalesstrickyway.for(i=0;i