问题描述
Question:Writeaprogramthatconsistsofthefollowingclassestodemonstratetheconceptofcomposition.classFactorwithamethodisFactor()whichisusedtotaketwovaluesxandyandreturntrueifyisafactorofx,falseifitisnot.classPerfectwithamethodisPerfect()whichisusedtotakeavaluezandreturntrueifthevaluezisaperfectnumber,falseifitisnot.ClassperfectwilluseclassFactortofindthefactorsofz.classClientusedtoreadinapositivevaluefromtheuseranddisplaymessagewhetherthevalueisaperfectnumberornot.TheclasswilluseclassPerfecttofindouttheresult.
时间: 2024-10-06 05:15:59