Skip to content

Instantly share code, notes, and snippets.

@mtahiriqbaldeveloper
Created March 9, 2023 21:56
Show Gist options
  • Save mtahiriqbaldeveloper/3697f384ebd0b8c9b5ec989c2780245d to your computer and use it in GitHub Desktop.
Save mtahiriqbaldeveloper/3697f384ebd0b8c9b5ec989c2780245d to your computer and use it in GitHub Desktop.
NutritionFacts telescoping
public NutritionFacts{
private int servingSize; //required
private int servings; //required
//optional parameters initialized to default values
private int calories; // optional
private int fat; //optional
private int sodium; //optional
private int carbohydrates; //optional
public NutritionFacts(int servingSize, int servings){
servingSize = servingSize;
servings = servings;
}
public NutritionFacts(int servingSize, int servings, int calories, fat){
servingSize = servingSize;
servings = servings;
calories = calories;
fat = fat;
}
public NutritionFacts(int servingSize, int servings, int calories){
servingSize = servingSize;
servings = servings;
calories = calories;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment