Critical Thinking Budgeting – Cryon Corporation*****A++ Rated Tutorial Already***** Use as a Guide Paper*****
August 8, 2017
Does social media enhance or hinder interpersonal relationship
August 8, 2017
Show all

A+ Answer

Create a class calledDateProfilethat has the followingprivate instance members: gender- achar, the gender of the applicant (‘M’ or ‘F’). searchGender- achar, the gender of desired partner (‘M’ or ‘F’). This is not the gender of the applicant, but of the applicant’s requested partner. romance- anintfrom 1 to 10, indicating the importance of romance to the applicant. finance- anintfrom 1 to 10, indicating the importance of finance to the applicant. name- astringindicating the full name of the applicant. Each object in theDateProfileclass represents an applicant’s profile. If the object is (‘M’, ‘F’, 7, 4, “Hugh Hefner”) then the applicant’s name is “Hugh Hefner”, he’s looking for a date who is Female, with romance being somewhat important (7) and finance being less important (4). Createpublic static constantsfor: All range limits (likeMIN_ROMANCE,MIN_NAME_LEN, etc.). These are the limits that the mutators test for. All default values (likeDEFAULT_GEND,DEFAULT_SEARCH_GEND,DEFAULT_NAME). These are used if the default constructor is called or if a parameter-taking constructor is called but a bad value (out-of-range) is detected. However, they are not used directly in the constructors, as we will find that there are helper methods that do the dirty work for the constructors — see below. You should supply all of the followingmember functionsof classDateProfile(at a minimum): AccessorsandMutatorsfor each field (instance member). For example:char getGender()andbool setGender(char gdr). In addition to individual mutators, create a publicvoid setAll( … )that takes all five parameters and acts like a mutator, except that it has a void return type, i.e., in this one, you do not have to report bad parameters back to the user, even though you would still filter them out. Also, create a publicvoid setDefaults()that sets all five members to their default values. Constructorsthat take no parameters (default) and all 5 parameters. To avoid code duplication make sure these constructors utilize the above mutators rather than do anything direct assignments or testing. double fitValue(DateProfile partner), which returns a number from 0.0 (very bad fit) to 1.0 (perfect fit). Thepublic instance methodcompares the calling object (this) to the object passed as a parameter. This method should call threeprivatemethodsdetermineGenderFit( … ), determineRomanceFit( … )anddetermineFinanceFit( … ), that will be used to return intermediate results for each of the three factors. It should compute the final fit value that it returns by returning a 0 if gender is not compatible (regaredless of the other values) and return theaverageof finance and romance values if gender is compatible. double determineGenderFit(DateProfile partner)Thisprivate instance methodreturns either a 0 or 1 depending on the gender compatibility of the calling object and the passed parameter object. You have to compare gender compatibility completely: i.e., there must bemutualconsent on this one! It is used by the publicfitValue(), not directly by the clientmain(). double determineRomanceFit(DateProfile partner)Thisprivate instance methodreturns a number from 0.0 to 1.0 depending on theromancecompatibility of the calling object and the passed parameter object. Theromancenumbers should be highest (1.0) if the two values are equal (both 3, both 5, both 7) and lowest (perhaps a small non-zero value like .1) if their difference is 9. It is used by the publicfitValue(), not directly by the clientmain(). double determineFinanceFit(DateProfile partner)Thisprivate instance methodreturns a number from 0.0 to 1.0 depending on thefinancecompatibility of the calling object and the passed parameter object. Thefinancenumbers should be highest (1.0) if the two values are equal (both 3, both 5, both 7) and lowest (perhaps a small non-zero value like .1) if their difference is 9. It is used by the publicfitValue(), not directly by the clientmain(). The Client Driver In addition tomain()supply a global scope method of that compares and displays twoDateProfileobjects: void displayTwoProfiles( DateProfile profile1, DateProfile profile2 )This method will print the names of the two objects and show the fit value. It’s output for a single call will look like this: Fit between Joe Somebody and Jane Peabody: 0.888889 From yourmain(), you will instantiate a total of fourDateProfileobjects,applicant1, … applicant4manually from literal values in your program, i.e., do not involve the user with run-time input. Then for each of the four applicants, display thefitswith the others – including themselves. Do this by callingdisplayTwoProfiles()for all possible combinations of the four applicants producing 16 comparison figures. (You will be comparing each applicant to him/herself in each of these four groups. This will serve to check whether the result is correct – it must be either a 1 or a 0 depending on thesearchGenderthey requested, but never a number between (can you see why?)). Here is part of a sample output: Fit between Joe Somebody and Joe Somebody: 0 Fit between Joe Somebody and Steve Nobody: 0 Fit between Joe Somebody and Jane Peabody: 0.888889 Fit between Joe Somebody and Helen Anybody: 0.833333 Fit between Steve Nobody and Joe Somebody: 0 Fit between Steve Nobody and Steve Nobody: 0 Fit between Steve Nobody and Jane Peabody: 0.666667 … Make sure all mutators, constructors and other methods that affect private data adequately test for illegal values and, if possible, return aboolthat reports the results of this test.

Leave a Reply

Your email address will not be published. Required fields are marked *