[VIEWED 7077
TIMES]
|
SAVE! for ease of future access.
|
|
|
zeePa
Please log in to subscribe to zeePa's postings.
Posted on 10-13-08 3:10
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
This is small java challenge to all java beginners, and pros. Well i am trying to do it and not yet being able to work it out! Let me see if you can get it to work... "Write overloaded Java methods that return the difference of two parameters. Your methods should contain the logic to return the difference of the larger parameter – smaller parameter, regardless of parameter order. Provide enough test code to ensure your methods are logically correct. The following table displays the required method parameter variations. Parm 1 Type Parm 2 Type Return Typeint int Intdouble double doubleint double doubledouble int doubleContinue to properly document your source code."
|
|
|
|
KillEmAll
Please log in to subscribe to KillEmAll's postings.
Posted on 10-13-08 3:13
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
what part r u stuck @? what does your pseudo code look like?
|
|
|
yellow
Please log in to subscribe to yellow's postings.
Posted on 10-13-08 5:10
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
I am new to java myself, not Sure if it has templetes. If it was C++ you can make one Templete instad of overloading function with variaty of parameters. If you start writing functions ( or methods) the possible combinations of parameters can be quite high, and redundant. I like the cast but then again the question asks for difference, ( which might get messed up because of loss of data). Hope someone can come up with solution. P.S If its just int and double, there are only four Methods to be written, which should be a no brainier.
|
|
|
sathi_mero
Please log in to subscribe to sathi_mero's postings.
Posted on 10-13-08 5:16
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Its better to post ur queries related to java in java forum... the url is java-forums.org.. u'll get perfect guidance...
|
|
|
techGuy
Please log in to subscribe to techGuy's postings.
Posted on 10-13-08 5:49
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Hope you know what function overloading is. Here are the declarations for overloaded method diff(). This is just to give you a start. Define these functions, test the defined functions from the main with different parameters. public int diff(int a , int b, int c); public double diff(double a, double b, double c); public double diff(int a, double b, double c); public double diff(double a, int b, double c); Post your code. If you are stuck somewhere. PS: Use some IDE like Eclipse or Netbeans that will save ur time.
Last edited: 13-Oct-08 05:50 PM
|
|
|
yellow
Please log in to subscribe to yellow's postings.
Posted on 10-13-08 6:00
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Thanks Suike for the info on Generics. I will do some more research.. but why do you say careful with login ID ? Also, why dont people Google for stuffs. and with all due respect, I don't think our fellow Nepalis know about other forums besides Sajha
|
|
|
yellow
Please log in to subscribe to yellow's postings.
Posted on 10-13-08 10:58
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Suike you are scaring me dude, I have hardly had 20 posts in Sajha, and
this nick yellow. I have not used anywhere. and yet you know who I am. Not just programing skills, you have some serious social engineering skillz. *bows* Now How do I find out who you are. ( how to send Msg in this forum)
|
|