Created
October 17, 2018 20:00
-
-
Save sajjadyousefnia/cd38fbd2fa3b604fc35b55471aa9de2b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaBeans Pattern - allows inconsistency, mandates mutability | |
public class NutritionFacts { | |
// Parameters initialized to default values (if any) | |
private int servingSize = -1; // Required; no default value | |
private int servings | |
= -1; // Required; no default value | |
private int calories | |
= 0; | |
private int fat | |
= 0; | |
private int sodium | |
= 0; | |
private int carbohydrate = 0; | |
public NutritionFacts() { } | |
// Setters | |
public void setServingSize(int val){ | |
servingSize = val; | |
} | |
public void setServings(int val) { | |
servings = val; | |
} | |
public void setCalories(int val) { | |
calories = val; | |
} | |
public void setFat(int val){ | |
fat = val; | |
} | |
public void setSodium{ | |
sodium = val; | |
} | |
public void setCarbohydrate(int val){ | |
carbohydrate = val; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment