• Post Reply Bookmark Topic Watch Topic
  • New Topic

DateProfile  RSS feed

 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I put together a DateProfile program which compiles, however I have two problems that have confounded me, they are as follows:
1. My method that configures the FitValue should return a number from 0.0 (bad fit) to 1.0 (perfect fit). It compares the calling object (this) to the object passed as a parameter. However, it allows fit values of the same sex to sneak in. For example, when I compare a male to a male or a female to a female the method should return 0.0, not a number between 0.0 and 1.0.
2. When I call my matchString to compare applicant1 to applicant1 I always get a perfect match (1.0). I would like to get a bad fit (0.0). The matchString works well when I use it to compare applicant1 with the other applicants.

Here is the code that concerns the above noted problems: In my main I created four new objects. Tom James and Michael Loceff are males seeking females, the 1st number concerns their romantic interest and the next number concerns the importance of finance to them. The other two objects are female and they are seeking male companions. The numbers denote the importance of romance and finance.



Here are the methods in my class DateProfile that pertain to the above noted data.



The next method returns either 0 or 1 depending on the gender compatibility of the calling object and the passed parameter object.

Next, console output for Tom James when I compare him to the other applicants. One will notice right away the two problems mentioned above. One, the fit with Tom James when applicant1 is compared with applicant1 is 1.0. Secondly, the fit with Michael Loceff who is a male like Tom is 0.04000000000000001. It should read 0.0.

I have tried in vain using if/else to twist some of these methods noted above to give me the results I want, but to no avail. I hope you can guide me in the right direction to get the outcome I desire concerning this program.

 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use the code button rather than writing code tags by hand; I have corrected them for you.

Those methods are confusing, and too long. Please don't start method names with CapitalLetters (you do that in C#, not in Java).

Try one method only at first. Get that working before you try adding the other methods.
And those if...return...else...return things can be simplified a lot, as you can see here (I think).
You end up with something likeNow, you need to work out what the .... means. I has to be a boolean of some sort. It will be much easier to understand if the first value (in ?…:‍) is what you return if it evaluates to true and the second (in :…;) if it is false.
General rule of thumb: you can understand true much more easily than false.
Now, you need to work out what the actual boolean formula is. Write it down on paper. Now you have got that and not before, try to work it out in code. If you have boy‑meets‑girl, write down her gender and sought gender, and do the same for him.

How do you know you will always have 'M' 'F'? Why not use a Gender enumerated type? Why are you returning a String, which obscures the numbers? Why not have a Couple class, which can encapsulate the two Dates and their compatibility score?

I suspect some of the code will not compile because there are potential paths through the methods which do not return results.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would add that your DetermineGenderFit() method doesn't make sense, and doesn't jive with the rules you spelled out.

Case 1: You don't allow same-sex couples. (This is what you stated in your post.) In this case, there's no need for an explicit "search gender". The "search gender" is implicitly the opposite of the current profile's gender. Your DetermineGenderFit() method then just has to check if this profile's gender is the opposite of the partner's gender.

Case 2: You do allow same-sec couples. In this case, you can still simplify your DetermineGenderFit() method. A single statement that returns 1.0 if this gender matches partner's desired gender and partner's gender matches this profile's desired gender, else 0.0.

 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed a few things. I eliminated my DEFAULT GENDER and DEFAULT SEARCH_GENDER. Then in my default constructor I added SetGender('M') and SetSearch_Gender('F'). I rewrote the gender fit method as follows:

(I pushed the code button to write the code above. Do I push it again to stop it?)

My output was the same as before. I also tried putting an if statement in the public boolean SetGender method that asked for a false statement if applicant and partner had the same gender. I also did this in the public boolean SetSearchGender method. That did not change anything. Next I tried putting a char in the arguements of the GenderFit method. Those were rejected by my compilier.

You asked me write on a piece of paper what I wanted to do first. Here it is. If the applicant's gender is male and the partner's gender is female and if the applicant's gender is female and the partner's gender is male then the method prints 1.0. Else the method prints 0.0.

The enum looked interesting, but I have never studied or used them. However, I think I could write one, but fitting it into my program may be problematic but I could try. Any further suggestions?

I really appreciate all the help you and your colleagues have given to me. In the past I have been doing these exercises on my own. I do not know anyone who writes programs. At any rate I just signed up to study java online with the company you work for and I think it will help me a lot. You have shown me that the way expressions are written in java has changed. Now they are shorter and more to the point. Thanks again!
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(I pushed the code button to write the code above. Do I push it again to stop it?)

No, you highlight all the code and then press the code button, see UseCodgeTags (← click).

If getGender() is returning a String then the solution to your problem can probably be found in AvoidTheEqualityOperator (← click).
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
reply to Tony Docherty

Thanks for your reply. I am not after a String. I am working with chars and I cannot invoke equals(char) on the primitive type char. I could not access the site you noted concerning code, but I think I understand what you are trying to say.
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A nit-picking sidenote: GetGender is against the usual naming conventions: type names are capitalized, but method names not.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could not access the site you noted concerning code, but I think I understand what you are trying to say.

Sorry there was typo in the name, try this UseCodeTags (← click).

You asked me write on a piece of paper what I wanted to do first. Here it is. If the applicant's gender is male and the partner's gender is female and if the applicant's gender is female and the partner's gender is male then the method prints 1.0. Else the method prints 0.0.

I don't know if I have missed something here but if the applicant's gender is male and the partner's gender is female how can the applicant's gender also be female and the partner's gender be male?
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reply to Tony Docherty

If you scroll up to the start of my DateProfile post (3 June, 2013 03:48:10) you will see the four objects I created. Two of the applicants are male ( the first char after the name denotes that fact) and two female applicants. I used applicant1 as an example: Tom James, he is male and he is searching for a female. His "romance importance on a scale of 1 to 10 is 9. His finance score on a scale of 1 to 10 is 5.

Two of the applicants are female and they are searching for males. My private char gender is the gender of the applicant('M' or 'F') and my private char searchGender is the gender of desired partner ('M' or 'F').

I want my determineGenderFit(DateProfile partner) method to match Tom James (a male) with female applicants only for a score of 1.0. I want the same for my female applicants (a male partner).
No same sex couples allowed. For example, Tom James matched to Tom James or Tom James matched to Michael Loceff ( a male) the method should return a 0.0.

If you look at the console output (post: 3 June, 2013) I believe that I have two separate problems.
1. Tom James compared to Tom James gives me 1.0. It should be 0.0. I have not tried to fix this problem yet.
2. Tom James compared to Michael Loceff ( a male) gives me a fit of 0.4. It should give a fit of 0.0. I also have this problem on matches to female to female. This is the problem that I am trying to fix first.
Any suggestions would be greatly appreciated.
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reply to Ivan Jozsef Balazs

Thanks for your input. The Sheriff made note of that too. I was taking an online course some time ago and the instructor made those mistakes in the description of the exercise and he did the same in his sample program. I thought that I had better follow his naming conventions or otherwise I might have points deducted. If you scroll down to the bottom of the page where the Sheriff listed some other programs to look at, the first one you see is another DateProfile program. This student did the same thing as I did because he had the same instructor. When I sort out my logic problems in this program I will go through the entire program and make the changes to the mistakes noted by you and the Sheriff. I was being a sheep and not doing what I should have done in the first place.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lee shotwell wrote:Reply to Tony Docherty
If you scroll up to the start of my DateProfile post (3 June, 2013 03:48:10) you will see the four objects I created. Two of the applicants are male ( the first char after the name denotes that fact) and two female applicants.
lee shotwell wrote:
DateProfile applicant1 = new DateProfile("Tom James", 'M', 'F', 9, 5);
DateProfile applicant2 = new DateProfile("Jantima Shotwell",'F', 'M', 2, 8);
DateProfile applicant3 = new DateProfile("Michael Loceff", 'F', 'M', 6, 2);
DateProfile applicant4 = newDateProfile("Sumalee Sreenok", 'F', 'M', 7, 7);

If the first char parameter after the name denotes their sex then 3 of them are female.

I want my determineGenderFit(DateProfile partner) method to match Tom James (a male) with female applicants only for a score of 1.0.

Ok so the question is: "is this person's gender the same as I desire for my partner and is my gender the same as this person requires for their partner?"

As an aside, I don't understand why you are returning 1.0 or 0.0 surely this is a boolean result ie either their respective partner's gender is appropriate or it is not.

1. Tom James compared to Tom James gives me 1.0. It should be 0.0. I have not tried to fix this problem yet.

I would fix this problem first as if comparing an object to itself is failing there really is a problem with your code rather than the data. I suggest you add a print statement to your DetermineGenderFit() method to print out the values returned by your SearchGender() and getGender() methods for both objects.
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lee shotwell wrote:the instructor made those mistakes in the description of the exercise...


Ok, the instructor is close and I am far ;-)
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lee shotwell wrote:I was taking an online course some time ago and the instructor made those mistakes in the description of the exercise and he did the same in his sample program. I thought that I had better follow his naming conventions or otherwise I might have points deducted. If you scroll down to the bottom of the page where the Sheriff listed some other programs to look at, the first one you see is another DateProfile program. This student did the same thing as I did because he had the same instructor. When I sort out my logic problems in this program I will go through the entire program and make the changes to the mistakes noted by you and the Sheriff. I was being a sheep and not doing what I should have done in the first place.

So I think we need clarification:

Do you still have a problem? And, if so: What is it?

And if you DO still have a problem, could you please furnish us with the relevant bits of your DateProfile class? I still have no idea what fields it contains.

I'm also a bit worried that I'm thinking about a DateProfile as an "it" - aren't these people?

Winston
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reply to Tony Docherty

I made a mistake on my code for appliocant3. Applicant3's gender should read 'M' and he desires a 'F'. Hence, I have two male objects and two female objects.

I had a problem with printing out the values of my DetermineGenderFit() method because I would need to change my method from a double to a boolean, plus the compilier says I would to change the set method from a char to a boolean. I end up with a "type mismatch" statement from my compilier. What I did do is set the romance and finance numbers with the same amounts (ex. 9,9) for the males and the females. My output gave me perfect matches (1.0) for male to male and female to female matches. Therefore, I do think that the method is reading the genders at all.

I have to find a way for my program to read the applicant' gender and the partner's gender correctly. I do not think that my code is set up to do that. Mr. Gutkowski asked me to make a post with all of the relevant bits of code which I will do now. Please look at the post.
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reply to Winston Gutkowski. Here are the relevant parts of my code. I only want fits between males and females. Fits between males should be 0.0 and fits between females and females should also be 0.0. Never a number in between. In the console output below you will see that when I compare Tom with Tom the output should be 0.0. Not 1.0. Secondly, the fit between Tom and Michael should be 0.0. Not 0.18. Those are my problems. Any assistance would be greatly appreciated.



console output:

 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does this even compile? Or I am missing something (like a dot or whatnot)?

 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does your getGender() method take a parameter which it then doesn't even use?

Your setGender() method isn't actually setting the gender and it is testing for whether the passed in value is valid if it is female (ie F ir f) and the current search_gender value is male (ie M or m)- this looks like a copy and paste error to me. It also shows why it's is better to give parameters different names to instance variables - if you had given it a different name you would have had a compilation error.

Your setSearchGender() method is setting the gender and not the search_gender.

As I said earlier add a print statements to your determineGenderFit() method to see what values it is actually comparing. But remember to fix the above issues first.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan Jozsef Balazs wrote:How does this even compile? Or I am missing something (like a dot or whatnot)?


There appears to be a bug in the forum display which sometimes causes underscores in variable names to not display. Strangely if you cut and paste the code in the original post the underscores are there, you just can't see them.
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reply to Tony Docherty

I isolated my method: private double determineGenderFit(dateProfile partner) to see how it scored my two female applicants and my two male applicants. I asked the method to return(this.getGender(gdr)) == (partner.getSearchGender(gdr)) ? 1.0 : 0.0; and the method returned 1.0 for all of the applicants. Furthermore, I had set each applicant's gender, wanted gender, romance #, and finance # separately with a System.out.println() method. I do not understand why my program returns 1.0 for both males and females after I had set each of the applicant's gender before I ran the program. Any suggestions?
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you added print statements so you can see what is actually happening as opposed to what you think should be happening.

I would start by printing out the values returned by this.getGender(gdr) and partner.getSearchGender(gdr)
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reply to Tony Docherty
Yes I added print statements and it printed out my dateProfile default chars which are gender = 'n'; and search_Gender = 'n'; I have written out new if statments for my determineGenderFit(dateProfile partner) method. They are as follows:
Object applicantGender;
Object partnerGetSearchGender;
if(applicantGender.equals('M')) && (partnerGetSearchGender.equals('F'))
return 1.0;
if(applicantGender.equals('F')) && (partnerGetSearchGender.equals('M'))
return 1.0;
else
0.0;
But, my compilier states that: I have a syntax error on token "&&" if expected. If I did that, my code would not work the way it should. Is there a way to make it work? If so I think my program might work correctly. Thanks for your help.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you show us exactly what code you ran and exactly what it printed out when you ran it we are all just guessing at what the problem might be.

Please remember to use code tags when posting code, even if it is just a snippet.

Your new if statements won't compile and won't work if they did compile for a whole host of reasons but aside from that they have the opposite logic to your previous attempt. Your original code said if the applicants gender and user's required gender are the same return 1 whereas your new code is saying if the genders are different return 1. Which logic do you want?
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lee shotwell wrote:I only want fits between males and females. Fits between males should be 0.0 and fits between females and females should also be 0.0. Never a number in between.

A might conservative in these enlightened times methinks .

However, notwithstanding that, if that's what you want, then why not make that a basic criteria, rather than faffing about with a ...Fit() method for it? It sounds to me like there's some sort of formula for your "fit factor", based on other things; but if two applicants are the same sex, then why even bother calculating it?

What might be worth having, though, is a canFit() method, viz:(assumes that you've corrected the mistake Tony pointed out)

I'm also not sure why you have a "search Gender". It seems redundant to me - particularly in light of your Draconian "gender-compatibility" rule.
I also suspect (as I said in my previous post) that you are confusing the business of the applicant with the search.

An Applicant doesn't need a search gender. Indeed, an Applicant, and a search for Applicants are two completely separate things; yet you've mixed them together with your DateProfile class.

And that's where most of your problems are coming from.

HIH

Winston

PS: I hope you reply a bit more quickly this time. It's a bit difficult to come back to threads after 12-13 days.
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reply to Tony Docherty and Winston Gutkowski: Here is all of my code as of 23/July/2013. I will type it because I have trouble with the paste process.

console output:

Comments: The applicants' fits with themselves should not be 1.0. They should be 0.0. Otherwise, this program will work depending upon the numbers I enter for romance and finance. However, the applicants' fits with themselves always stays at 1.0. I am sorry for not getting back to you sooner. I have been trying to sort this out without bothering you in that I know you are very busy, but I just do not seem to be able to do it. Your help is greatly appreciated and I have spent a lot time going over your notes to me.



 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lee shotwell wrote:Comments: The applicants' fits with themselves should not be 1.0. They should be 0.0.

Then why are you returning it? I can see at least 3 places that you are.

Otherwise, this program will work depending upon the numbers I enter for romance and finance.

But you're not. You still have a genderFit() method. I know what you're trying to do, but it's plainly not working; so why not do what I suggested above and only calculate your formula if the genders don't match. For one thing: checking a boolean is probably 50 times faster than doing floating-point arithmetic.

You also seem to have added an awful lot of code to a program that isn't working. A sure recipe for disaster. And you also haven't taken on board what I said about separating applicants from searches, because you still have a "search gender".

My advice: StopCoding (←click). Chill out. Have a fag. Go down the pub (if you're old enough), and put some distance between you and this problem. Then get out lots of paper, re-read all the replies you've been given, and start again, and don't write a line of Java code until you understand the problem forwards, backwards and sideways.

You may well find you can re-use some of the code you've written, but you will never code your way out of a mess.

Winston
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reply to Winston Gutkowski's msg. dtd 23 July, 2013
The instructions for this assignment are why I am doing the things you noted. I am to create a class called DateProfile that has the following private members:
gender - a char the gender of the applicant ('M' or 'F').
search_gender - a char, the gender of desired partner ('m' or 'F'). This is not the gender of the applicant, but of the applicant's requested partner.
romance - a double from 0.0 to 1.0, indicating the importance of romance to the applicant.
finance - a double (same as above for romance).
name - a String indicating the full name of the applicant.

Each object in the DateProfile class represents an applicant's profile. For example, (Hugh Heffner, 'M', 'F', 7, 4).

you should supply all of the following (at a minimum):

Accessors and Mutators for each field (instance member). For example: char getGender() and boolean setGender(char gdr)

These methods are required: double fitValue(DateProfile partner), double determineGenderFit(dateProfile partner) 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 be mutual consent on this one!, double determineRomanceFit(DateProfile partner), double determineFinanceFit(DateProfile partner).

You should instantiate a total of four DateProfile objects (applicants 1 through 4). Then for each of the four applicants, display the fits with the others. Do this by showing the name of the applicant, then the names and fit values of all the applicants relative to this one applicant (repeat the applicant in his/her own list to see if result is correct - it will be either a 1 or a 0 depending on the search_gender they requested, but never a number between (why?)). Repeat this list for all four applicants: This is the assignment example.

Hugh Heffner
Carmen Miranda fit: 0.82314
Brad Pit fit: 0.0
Mary Lynn Rajskub fit: 0.6302
Hugh Heffner fit: 0.0
Carmen Miranda
Carmen Miranda fit: 0.0
Brad Pit fit: .72029
Mary Lynn Rajskub fit: 0.0
Hugh Heffner fit: 0.82314 ... etc.

Hence, Winston the reason I am returning the applicants fits with themselves is because that is what the assignment calls for. Secondly, the reason I still have a genderFit method is because the assignment required that I have one. I will create a method, as you suggested, where the genders do not match which I think might still fit in with the so-called gender compatibility asked for in the genderFit method metioned in the assignment. In the end, I am still confused, but going over what you have said, it is possible that this assignment was not thought out completely by the person that wrote it, however I do not have enough knowledge about coding to come to a conclusion. I will take your advise and go out to a pub tonight and have a few beers and forget about coding for a few hours. Then I will study again what you have said and go back through my notes. Thanks again for all of your insight. On a lighter note concerning date profiling recently over here the police took a man down to their station because he had been mauled badly. They thought someone had tried to rob him because he was clearly drunk. But no, he had been drinking with his friends and he ran out of money. While walking home he saw a cute frisky dog that caught his eye. Well, she (the dog) wasn't in the mood so she bite and scratched him badly. The police asked him if he does this often and he replied, well yes, he said girls are costly, but dogs are free. Anyhow, have a good day.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will type it because I have trouble with the paste process.

Typing in the code is pointless as it will almost certainly contain typos etc (and it's full of them) and so it isn't the exact code you are running which means we can't look at it and tell if an error we spot is the actual problem or just a typo.
Why can't you cut and paste the code in?

double determineGenderFit(dateProfile partner) 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 be mutual consent on this one!,

Ok so you should be checking if this person's required partner is the same sex as the person passed in and if the person passed in's required partner is the same same is this person.
Note this isn't the reason your code isn't working, it's a requirement shortfall and I wouldn't recommend attempting to fix this until you have fixed the underlying problem.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lee shotwell wrote:The instructions for this assignment are why I am doing the things you noted. I am to...

Then this is what you should have told us at the start, because it's incredibly important.

I also see nothing in the instructions you've shown us that stops an applicant wanting to search for someone of their own gender, which is definitely not what you said earlier.
Or maybe it's a restriction that you haven't told us about imposed on clients - in which case you still don't need a search gender field (assuming there are only 2), because you won't be able to create an applicant that wants to search for the same gender; ie, searchGender == gender == male ? female : male.

Other than that: What Tony said.

But glad to hear you're taking my advice about the pub.

Winston
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reply to Tony Docherty and Winston Gutkowski
I tried to paste and now I have lost my entire class DateProfile so I will have to create it again. What I need are clear and concise instructions on how to paste into this website. The way I tried to do it were as follows: Ctr a > Ctr v > return to moose website > push code button > Ctr v (to paste).
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lee shotwell wrote:Reply to Tony Docherty and Winston Gutkowski
I tried to paste and now I have lost my entire class DateProfile so I will have to create it again.

Copying a file should not delete your original file regardless of whether or not you can paste it into this site.

lee shotwell wrote:Reply to Tony Docherty and Winston Gutkowski
What I need are clear and concise instructions on how to paste into this website. The way I tried to do it were as follows: Ctr a > Ctr v > return to moose website > push code button > Ctr v (to paste).

Ctr a - this will select all text in your editor
Ctr v - this will paste whatever is in your copy buffer over the selected text. If you haven't copied anything to the buffer since turning on your machine it will be empty and so, effectively, it will just delete all selected text. You need to use CTRL+C to copy the selected text. BTW most editors support CTRL+Z to undo the last action which would have recovered your code.

On our site paste the code into the editor using CTRL+V, select all of the code and then press the code button.
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reply to Tony Docherty and Winston Gutkowski:

I am amazed Tony, the paste operation went fine so now you have my code without errors. I tried to enter the private boolean canFit method into my class DateProfile that Winston gave me, but my compiler said, "The method canFit(DateProfile) from the type DateProfile is never used locally. Remove method canFit." However, I did create accessors (set/get) for it. I tried to work it into the DetermineGenderFit(DateProfile partner method, but I could not find a way to make it fit. I used search_gender to set the gender of the partner. If I use == in the DetermineGenderFit method the program will give me fit numbers (see the console output I posted earlier). If I use != in the before mentioned method I get all 0.0. Winston said that there is not anything in the exercise instructions that prohibit an applicant selecting a same sex partner. Winston is right, however I assumed that was not what the instructor wanted because in his sample output, which I posted to you already, he only showed males selecting females and females selecting males only. Furthermore, the instructor showed that he wanted a 0.0 value when an applicant is compared to him/herself. Tony, thanks again for your good instructions on how to paste the code, it really saves me a lot of time and you will not be upset with my typed code anymore.
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Msg. to Tony Docherty and Winston Gutkowski

I made a post to this site on 30 July, 2013 at 06:51:48. I encluded a paste of my complete program with comments. Did you receive it? I ask because when I looked for my post at the site, I did not see it so I went to Java in General > DateProfile and saw a notation that I had made a post. Hence, there it was. I do not mean to bug you because I know you are very busy. Again, thanks for all he help you have provided me concerning this frustrating program. Give me a post only when you have the time to do it.
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To: Jeff VERDEGAN
From: Lee SHOTWELL
Subject: DetermineGenderFit method
Reply to your msg. dtd. 3 June, 2013

In your msg. you mentioned two cases. My program is concerned with case 1 only. When I use != I get 0.0 100% in my console output. If I use == my output (see console output in my post dtd.23 July) compares oposite and same sex which I do not want. My post dtd. 24 July states the exercise requirements for this program. Tony asked me to paste my complete program on this site (29 July) so I did so on 30 July. Tony DOCHERTY and Winston GUTKOWSKI had been helping me, but after I pasted my complete program, I have not heard from them. I would really like to finish this program and move on. Any assistance would be greatly appreciated and if you currently do not have any time to spare maybe you could refer me to someone that does. In the past this site was very helpful to me concerning another program. Thanks!
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To: Jeff VERDEGAN
From: Lee SHOTWELL
Subject: DetermineGenderFit method
Reply to your msg. dtd. 3 June, 2013

In your msg. you mentioned two cases. My program is concerned with case 1 only. When I use != I get 0.0 100% in my console output. If I use == my output (see console output in my post dtd.23 July) compares oposite and same sex which I do not want. My post dtd. 24 July states the exercise requirements for this program. Tony asked me to paste my complete program on this site (29 July) so I did so on 30 July. Tony DOCHERTY and Winston GUTKOWSKI had been helping me, but after I pasted my complete program, I have not heard from them. I would really like to finish this program and move on. Any assistance would be greatly appreciated and if you currently do not have any time to spare maybe you could refer me to someone that does. In the past this site was very helpful to me concerning another program. Thanks!
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To: Jeff VERDEGAN
From: Lee SHOTWELL
Subject: DetermineGenderFit method
Reply to your msg. dtd. 3 June, 2013

In your msg. you mentioned two cases. My program is concerned with case 1 only. When I use != I get 0.0 100% in my console output. If I use == my output (see console output in my post dtd.23 July) compares oposite and same sex which I do not want. My post dtd. 24 July states the exercise requirements for this program. Tony asked me to paste my complete program on this site (29 July) so I did so on 30 July. Tony DOCHERTY and Winston GUTKOWSKI had been helping me, but after I pasted my complete program, I have not heard from them. I would really like to finish this program and move on. Any assistance would be greatly appreciated and if you currently do not have any time to spare maybe you could refer me to someone that does. In the past this site was very helpful to me concerning another program. Thanks!
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lee shotwell wrote:I made a post to this site on 30 July, 2013 at 06:51:48. I encluded a paste of my complete program with comments. Did you receive it? I ask because when I looked for my post at the site, I did not see it so I went to Java in General > DateProfile and saw a notation that I had made a post. Hence, there it was. I do not mean to bug you because I know you are very busy. Again, thanks for all he help you have provided me concerning this frustrating program. Give me a post only when you have the time to do it.

I'm afraid we don't get notified of posts (at least, I don't), so I only reply when I see some activity; and I've been following the Test Match for the last few days.

BTW, I've also added code tags to your post. See how much better it looks? I suggest you read the UseCodeTags (←click) page, and also the DontWriteLongLines one (although yours are fine).

I'll post again when I have comments.

Winston
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lee shotwell wrote:Winston said that there is not anything in the exercise instructions that prohibit an applicant selecting a same sex partner. Winston is right, however I assumed that was not what the instructor wanted because in his sample output, which I posted to you already, he only showed males selecting females and females selecting males only. Furthermore, the instructor showed that he wanted a 0.0 value when an applicant is compared to him/herself.

Ah. So you're extrapolating.

1. Ask your tutor if it was his intention not to allow same-sex dating, or just an omission in his "test examples". I suspect he may admit the latter.
2. Unless the agency is called "Narcissists Inc." or "AutoLove.com", his last requirement sounds perfectly reasonable. So: how do you check if an object is the same as another?

Also: I think you misunderstood my "canFit" idea. It's not a field, so you don't need a 'get' and 'set' method for it; it's a function.

The idea is that, given a "potential match" (which could be ANY DateProfile), the method eliminates ones that cannot possibly be a match for this DateProfile, and therefore aren't worth even trying to calculate - a classic example being that they are THE SAME PERSON.

HIH

Winston
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lee shotwell wrote:Reply to Tony Docherty and Winston Gutkowski

'NOT' and 'OR' don't mix well:

Take this statement:
if((gdr != 'M' || (gdr != 'F')))
(with or without the unnecessary brackets)
and stick it in a method on it's own. Then test it with every possible value for 'gdr' you can think of - including 'M' and 'F'.

What's the result?
Why do you think that is?

Now think about how you should write that statement, and test it in your little method - and don't write one more line of your program until your test method is working correctly.

Winston
 
lee shotwell
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reply to Winston GUTKOWSKI
An eureka moment has arrived. Forget about the draw at the Ashes. Your eagle eye caught the not/or mistake in my program. I changed the "or" to && in those statements. Plus, In the private double determineGenderFit(DateProfile partner) method I changed the == to !=. My program works the way it should. It only reads in the opposite sex and comes up with a fit. In regards to the same sex, the program gives me a 0.0 and it records a 0.0 when an applicant is evaluating him/herself. I deleted the canFit function. It is hard to believe, the program is finished. If you lived in Thailand, the drinks would be taken care of by me this evening at the local pub.

What do I need to do now? Is there a way to edit my pasted program so that it is correct? Thanks so much Winston. I am so happy.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!