Skip to content
Snippets Groups Projects
Commit 32b00a6f authored by aleksveg's avatar aleksveg
Browse files

refactored shipping cost

changed from short to int for id field. had to change parameter type on some methods as well 
parent 22d44446
No related branches found
No related tags found
1 merge request!70refactored shipping cost
...@@ -17,7 +17,7 @@ public class ShippingCost { ...@@ -17,7 +17,7 @@ public class ShippingCost {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private short id; private int id;
@Column(name = "description") @Column(name = "description")
private String description; private String description;
...@@ -35,7 +35,7 @@ public class ShippingCost { ...@@ -35,7 +35,7 @@ public class ShippingCost {
* @param description describes what the cost is * @param description describes what the cost is
* @param cost the price * @param cost the price
*/ */
public ShippingCost(short id, String description, double cost) { public ShippingCost(int id, String description, double cost) {
if (checkId(id) && checkCost(cost) && checkDescription(description)) { if (checkId(id) && checkCost(cost) && checkDescription(description)) {
this.description = description; this.description = description;
this.cost = cost; this.cost = cost;
...@@ -55,7 +55,7 @@ public class ShippingCost { ...@@ -55,7 +55,7 @@ public class ShippingCost {
// --------------------- Get methods ------------------------ // --------------------- Get methods ------------------------
public short getId() { public int getId() {
return id; return id;
} }
...@@ -78,7 +78,7 @@ public class ShippingCost { ...@@ -78,7 +78,7 @@ public class ShippingCost {
* *
* @return true if id is valid, false otherwise * @return true if id is valid, false otherwise
*/ */
private boolean checkId(short id) { private boolean checkId(int id) {
return id > 0; return id > 0;
} }
...@@ -90,11 +90,7 @@ public class ShippingCost { ...@@ -90,11 +90,7 @@ public class ShippingCost {
* @return true if the cost has legal value * @return true if the cost has legal value
*/ */
private boolean checkCost(double cost) { private boolean checkCost(double cost) {
boolean costIsValid = false; return cost >= 0;
if (cost >= 0) {
costIsValid = true;
}
return costIsValid;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment