renaming bigDecimalGrade method + removing the GENDER constant
This commit is contained in:
parent
12bc0fcfd9
commit
c1d88b7364
@ -0,0 +1,7 @@
|
|||||||
|
package com.baeldung.accessmodifiers.publicmodifier;
|
||||||
|
|
||||||
|
public class SpecialCharacters {
|
||||||
|
|
||||||
|
public static final String SLASH = "/";
|
||||||
|
|
||||||
|
}
|
@ -10,13 +10,12 @@ public class Student {
|
|||||||
private BigDecimal grade; //new representation
|
private BigDecimal grade; //new representation
|
||||||
private String name;
|
private String name;
|
||||||
private int age;
|
private int age;
|
||||||
public static final String GENDER = "male";
|
|
||||||
|
|
||||||
public int getGrade() {
|
public int getGrade() {
|
||||||
return grade.intValue(); //Backward compatibility
|
return grade.intValue(); //Backward compatibility
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal bigDecimalGrade() {
|
public BigDecimal getBigDecimalGrade() {
|
||||||
return grade;
|
return grade;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,9 +27,10 @@ public class Student {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAge(int age) {
|
public void setAge(int age) {
|
||||||
if (age < 0 || age > 150)
|
if (age < 0 || age > 150) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
this.age = age;
|
this.age = age;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.junit.jupiter.api.TestInstance;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||||
import com.baeldung.accessmodifiers.publicmodifier.ListOfThree;
|
import com.baeldung.accessmodifiers.publicmodifier.ListOfThree;
|
||||||
import com.baeldung.accessmodifiers.publicmodifier.Student;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
@ -22,16 +21,11 @@ public class PublicAccessModifierUnitTest {
|
|||||||
assertEquals(0, new BigDecimal(0).intValue()); //instance member
|
assertEquals(0, new BigDecimal(0).intValue()); //instance member
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenUsingGenderPublicStaticFinalField_getReferenceToStringMale() {
|
|
||||||
assertEquals("male", Student.GENDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenUsingIntegerMaxValueField_maxPossibleIntValueIsReturned() {
|
public void whenUsingIntegerMaxValueField_maxPossibleIntValueIsReturned() {
|
||||||
assertEquals(2147483647, Integer.MAX_VALUE); //static field
|
assertEquals(2147483647, Integer.MAX_VALUE); //static field
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenUsingStringToLowerCase_stringTurnsToLowerCase() {
|
public void whenUsingStringToLowerCase_stringTurnsToLowerCase() {
|
||||||
assertEquals("alex", "ALEX".toLowerCase());
|
assertEquals("alex", "ALEX".toLowerCase());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user