Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Assignment - Computer Dating

Make sure you have read and understood bothmodules AandBthis week, and module 2R

Requirements before submitting this assignment. Hand in only one program, please.

Date Profiles
Class DateProfile
Create a class called DateProfile that has the following private 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 the DateProfile class 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).

Create public static constants for:

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 following member functions of class DateProfile (at a minimum):

AccessorsandMutatorsfor each field (instance member). For example:char getGender()andboolean 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 that the parameter-taking constructor utilizes 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 method compares the calling object (this) to the object passed as a parameter. This method should call threeprivatemethods determineGenderFit( ... ), determineRomanceFit( ... ) and determineFinanceFit( ... ), 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 method returns 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 public fitValue(), not directly by the client main().

double determineRomanceFit(DateProfile partner) Thisprivate instance method returns a number from (but not including) 0.0 to (and including) 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 public fitValue(), not directly by the client main().

double determineFinanceFit(DateProfile partner) Thisprivate instance method returns a number from (but not including) 0.0 to (and including) 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 public fitValue(), not directly by the client main().

Make sure all mutators, constructors and other methods that affect private data adequately test for illegal values and, if possible, return a bool that reports the results of this test.

DateProfile should be a class distinct from (and not contained within) your main class (which we call Foothill). However, you can and should define it as a non-public class so it can reside in the same file, Foothill.java.

The Client Driver
In addition to main() supply a static method of class Foothill that compares and displays two DateProfileobjects:
static 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 Sarah Somebody and Jane Peabody: 0.395

From your main() inside Foothill, you will instantiate a total of four DateProfile objects, applicant1, ... applicant4 manually 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 the fits with the others - including themselves. Do this by calling displayTwoProfiles() 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 the searchGender they requested, but never a number between (can you see why?)). Here is part of a sample output (with an optional mutator test at the end):

Fit between Sarah Somebody and Sarah Somebody: 1.0
Fit between Sarah Somebody and Steve Nobody: 0.0
Fit between Sarah Somebody and Jane Peabody: 0.395
Fit between Sarah Somebody and Helen Anybody: 0.0

Fit between Steve Nobody and Sarah Somebody: 0.0
Fit between Steve Nobody and Steve Nobody: 0.0
Fit between Steve Nobody and Jane Peabody: 0.0
Fit between Steve Nobody and Helen Anybody: 0.78

Fit between Jane Peabody and Sarah Somebody: 0.395
Fit between Jane Peabody and Steve Nobody: 0.0
Fit between Jane Peabody and Jane Peabody: 1.0
Fit between Jane Peabody and Helen Anybody: 0.0

Fit between Helen Anybody and Sarah Somebody: 0.0
Fit between Helen Anybody and Steve Nobody: 0.78
Fit between Helen Anybody and Jane Peabody: 0.0
Fit between Helen Anybody and Helen Anybody: 0.0

Q rejected as gender

...

Java, Programming

  • Category:- Java
  • Reference No.:- M92405565
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Java

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As