Skip to content

Instantly share code, notes, and snippets.

@sajjadyousefnia
Created October 17, 2018 20:00
Show Gist options
  • Save sajjadyousefnia/cd38fbd2fa3b604fc35b55471aa9de2b to your computer and use it in GitHub Desktop.
Save sajjadyousefnia/cd38fbd2fa3b604fc35b55471aa9de2b to your computer and use it in GitHub Desktop.
// 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