Paweł Baczyński wrote:I seem to miss what the question/problem is.
Two remarks about your code:
Fields: age, muac, hip, wrist should be private Your equals method breaks the contract. An object should always be equal to itself.
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:@michael,
in your opening post, you have the arm, hip and wrist as non-integers, while these are defined as integers in your Female class.
What are they? And, for instance, does constant B (related to age?) also depend on arm, wrist and hip?
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:Okay, but then there is no reason for creating a HashMap with a Female as key.
Just create four HashMaps, with keys the arm, wrist, hip and age, and values
the respective constants.
It is not advisable to use a double as key, so try to map these doubles to
integers (for instance by measuring in mm in stead of cm).
Your BodyFat class then only needs a method that calculates the body fat, given
the four variables.
You could store all your measurements in a Female class, as already mentioned,
to be able to calculate all desired statistics.
Please explain. That looks a bit like parallel arrays. You should have some sort of object which encapsulates those four data. I think we already have one of them. The difficult part is finding the appropriate thing to use as a “K” in the Map.Piet Souris wrote:. . . Just create four HashMaps, with keys the arm, wrist, hip and age, and values the respective constants.
Why not? A double will be boxed to a Double, and that is an immutable object. The problem I can see is that you will try something likeIt is not advisable to use a double as key, . . .
Campbell Ritchie wrote:
Why not? A double will be boxed to a Double, and that is an immutable object. The problem I can see is that you will try something likePiet Souris wrote:It is not advisable to use a double as key, . . .
myMap.put(1.23, xxx)
and then not remember which “K” you used.
myMap.get1.2299999999999) won't find xxx.
Exactly. Why not have just a List<Female> ?salvin francis wrote:Apart from all the suggestions given above, I have a different perspective on this.
Why are you using a HashMap to store a multi - dimensions based data ?
A HashMap allows you to store a set of data in a key-value pair format. Based on your inputs so far, I feel that you just want a set of inputs and give the output based on some formula.
If you are going to base your output based on statistical records, its quite vague, but how will the application behave if the user enters a value thats not in your list ?
Carey Brown wrote:Exactly. Why not have just a List<Female> ?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:.. that encapsulates any differences in BMI calculation.
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|