-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tissue type field #96
Conversation
} else { | ||
for (int i = 0; i < tissuetypeValue.length; i++) { | ||
try { | ||
Integer tt = Integer.parseInt(tissuetypeValue[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no check for whether the tissue types are numbers from 1-12
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add check that all numbers is non duplication and from range 1-12.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually according to the link jiaying gave and google, there seems to be more than 12 types of tissue. But I cant really find a fixed number online on how manu types exactly. Should we just assume its 12?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some additional research. Apparently there are a lot more tissue types. We can stick to 12 tissues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok noted. Will change by tonight. I can make to 20 actually since I think the total type is more than 20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just stick with 12 for simplicity. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so just have a check if all number is <= 12 and there is non duplicate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so just have a check if all number is <= 12 and there is non duplicate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can add comment that its > 12 types but we are limiting it for now. Perhaps add //TODO: comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok noted
} | ||
|
||
@Test | ||
public void isValidTissuetype() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering, if I have an input string "1, 2, 3, 4, 5, 6", would it count?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, line 38 tested it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant if the input string will accept the inputs separated by a comma and a space. Line 38 tests if the inputs are separated by commas.
assertFalse(Tissuetype.isValidTissuetype("1 2 3 4 5 6")); // spaces within tissuetype | ||
|
||
// valid tissuetype | ||
assertTrue(Tissuetype.isValidTissuetype("1,2,3,4,5,6")); // exactly 6 tissuetype |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you include test cases for tissue types > 12? Eg 13, 14.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, line 45
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 45 tests the toString()
method, not the isValidTissueType()
method. Could you add test cases which checks for numbers that are not accepted as valid tissue types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! I've requested some changes.
If the PR fixes a certain issue please tag it by adding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
for (int i = 0; i < tissuetypeValue.length; i++) { | ||
try { | ||
Integer tt = Integer.parseInt(tissuetypeValue[i]); | ||
if (tt > 12) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a check for tt < 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please check for < 1. Can check together with > 12 in same line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall good job, do make the changes requested.
public final String value; | ||
|
||
/** | ||
* Constructs a {@code Bloodtype}. | ||
* | ||
* @param bloodtype A valid bloodtype. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to camelCase for all references of BloodType
or bloodType
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ctrl + shift +R for find and replace
* Represents a Person's tissue type in ORGANice. | ||
* Guarantees: immutable; is valid as declared in {@link #isValidTissuetype(String)} | ||
*/ | ||
public class Tissuetype { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CamelCase here as well ?
String[] tissuetypeValue = test.split(","); | ||
if (tissuetypeValue.length != 6 || isDuplicated(tissuetypeValue)) { | ||
return false; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we drop the else block to reduce indentation by 1 level? What does the code style say about this?
for (int i = 0; i < tissuetypeValue.length; i++) { | ||
try { | ||
Integer tt = Integer.parseInt(tissuetypeValue[i]); | ||
if (tt > 12) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please check for < 1. Can check together with > 12 in same line.
/** | ||
* Returns true if a given string array contains duplicate. | ||
*/ | ||
public static boolean isDuplicated(String[] test) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps hasDuplicates
or containsDuplicates
would be a better name
// invalid tissuetype | ||
assertFalse(Tissuetype.isValidTissuetype("")); // empty string | ||
assertFalse(Tissuetype.isValidTissuetype(" ")); // spaces only | ||
assertFalse(Tissuetype.isValidTissuetype("a,b,c,d,e,f")); // wrong tissuetype |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps would be better to say \\ tissue types must be Integers from 1..12
. The dots are intentional btw. ..
means range inclusive, ...
means range exclusive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @SimNee & @WilliamRyank
In the future please use the issue description to describe the issue. Leave comments such as travis and gradle to a follow up comment. Thanks |
This is due to the fact that when the issue is referenced elsewhere, your description will be shown when people hover over the link |
Added tissue type field and its test file. It passed travis and gradle as of now