Java project

profilerick07
recipe.zip

recipe/GERRARD DEWINDT Module 6 Code Reflection.docx

Page | 2

MODULE 6 CODE REFLECTION

GERRARD R. E. DEWINDT

20 APRIL 2019

Author Note

This paper was prepared for IT-511 Operating Systems, Module 6 Code Reflection,

Assignment, taught by Molin, Jamal.

Module 6 Code Reflection

I created a class ingredient. Within this class I created Arrays to collect the user data for the name of the ingredients, amount, unit of measure, and calories. I also created a variable to store the name of the recipe, the name of the user, and the user answer for getting out of the loop. When the program starts I ask the user to enter their name and the name of the recipe.

I added the instance variables for the class Recipe (recipeName, serving size, and recipeIngredients). I also added methods (the accessors/mutators, the constructors, and the extra print details method) for the class Recipe. I also created a custom method to print the recipe out to the console. I also used the SteppingStone5_RecipeTest.java file to test the functionality of the finished code. I don’t see any problem with my code but it keeps giving me an error about a quarter of the way through the program. I have tried everything not sure why my program isn’t working anymore.

1 | Page

recipe/RecipeManagerApp/build.xml

Builds, tests, and runs the project RecipeManagerApp.

recipe/RecipeManagerApp/build/classes/.netbeans_automatic_build

recipe/RecipeManagerApp/build/classes/.netbeans_update_resources

recipe/RecipeManagerApp/build/classes/recipemanagerapp/Ingredient.class

package recipemanagerapp;
public synchronized class Ingredient {
    private String nameOfIngredient;
    private String unitOfMeasurement;
    private float ingredientAmount;
    private double numberCalories;
    private double totalCalories;
    void Ingredient(String, String, float, double, double);
    void Ingredient();
    public double getTotalCalories();
    public void promptEnterRecipeName();
    public void promptEnterIngredName();
    public void promptEnterUnitOfMeasure();
    public void promptEnterIngredAmount();
    public void promptEnterCalorie();
    public void promptAddMoreIngred();
    public String getNameOfIngredient();
    public void setNameOfIngredient(String);
    public String getUnitOfMeasurement();
    public void setUnitOfMeasurement(String);
    public float getIngredientAmount();
    public void setIngredientAmount(float);
    public double getNumberCalories();
    public void setNumberCalories(double);
    public void setTotalCalories(double);
}

recipe/RecipeManagerApp/build/classes/recipemanagerapp/Recipe.class

package recipemanagerapp;
public synchronized class Recipe {
    private String recipeName;
    private int servings;
    private java.util.ArrayList recipeIngredients;
    private double totalRecipeCalories;
    public void Recipe(String, int, java.util.ArrayList, double);
    public void printRecipe();
    public static void main(String[]);
    public String getRecipeName();
    public void setRecipeName(String);
    public int getServings();
    public void setServings(int);
    public java.util.ArrayList getRecipeIngredients();
    public void setRecipeIngredients(java.util.ArrayList);
    public double getTotalRecipeCalories();
    public void setTotalRecipeCalories(double);
}

recipe/RecipeManagerApp/build/classes/recipemanagerapp/Validation.class

package recipemanagerapp;
public synchronized class Validation {
    public void Validation();
    public static void main(String[]);
    static Double getDouble();
    static String getString();
    static float getFloat();
}

recipe/RecipeManagerApp/manifest.mf

Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build

recipe/RecipeManagerApp/nbproject/build-impl.xml

Must set src.dir Must set test.src.dir Must set build.dir Must set dist.dir Must set build.classes.dir Must set dist.javadoc.dir Must set build.test.classes.dir Must set build.test.results.dir Must set build.classes.excludes Must set dist.jar Must set javac.includes No tests executed. Must set JVM to use for profiling in profiler.info.jvm Must set profiler agent JVM arguments in profiler.info.jvmargs.agent

recipe/RecipeManagerApp/nbproject/genfiles.properties

build.xml.data.CRC32=4b492756 build.xml.script.CRC32=89537af3 [email protected] # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=4b492756 nbproject/build-impl.xml.script.CRC32=a77c180e nbproject/[email protected]

recipe/RecipeManagerApp/nbproject/private/private.properties

compile.on.save=true user.properties.file=C:\\Users\\dewin\\AppData\\Roaming\\NetBeans\\8.2\\build.properties

recipe/RecipeManagerApp/nbproject/private/private.xml

file:/C:/Users/dewin/Desktop/RecipeManagerApp/src/recipemanagerapp/Validation.java file:/C:/Users/dewin/Desktop/RecipeManagerApp/src/recipemanagerapp/Recipe.java file:/C:/Users/dewin/Desktop/RecipeManagerApp/src/recipemanagerapp/Ingredient.java

recipe/RecipeManagerApp/nbproject/project.properties

annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processor.options= annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: build.dir=build build.generated.dir=${build.dir}/generated build.generated.sources.dir=${build.dir}/generated-sources # Only compile against the classpath explicitly listed here: build.sysclasspath=ignore build.test.classes.dir=${build.dir}/test/classes build.test.results.dir=${build.dir}/test/results # Uncomment to specify the preferred debugger connection transport: #debug.transport=dt_socket debug.classpath=\ ${run.classpath} debug.test.classpath=\ ${run.test.classpath} # Files in build.classes.dir which should be excluded from distribution jar dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist dist.jar=${dist.dir}/RecipeManagerApp.jar dist.javadoc.dir=${dist.dir}/javadoc excludes= includes=** jar.compress=false javac.classpath= # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false javac.external.vm=true javac.processorpath=\ ${javac.classpath} javac.source=1.8 javac.target=1.8 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir} javac.test.processorpath=\ ${javac.test.classpath} javadoc.additionalparam= javadoc.author=false javadoc.encoding=${source.encoding} javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=false javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= main.class=recipemanagerapp.Recipe manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false platform.active=default_platform run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} # Space-separated list of JVM arguments used when running the project. # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. # To set system properties for unit tests define test-sys-prop.name=value: run.jvmargs= run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} source.encoding=UTF-8 src.dir=src test.src.dir=test

recipe/RecipeManagerApp/nbproject/project.xml

org.netbeans.modules.java.j2seproject RecipeManagerApp

recipe/RecipeManagerApp/src/recipemanagerapp/Ingredient.java

recipe/RecipeManagerApp/src/recipemanagerapp/Ingredient.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  recipemanagerapp ;

/**
 *
 *  @author  gerrard.dewin_snhu
 */
public   class   Ingredient   {
    
      // These are the class variables.        
         private   String  nameOfIngredient ;
         private   String  unitOfMeasurement ;
         private   float  ingredientAmount ;
         private   double  numberCaloriesPerCup ;
         private   double  totalCalories ;
       
        
         String  noi ;
         String  uom ;         
         float  ia ;
         double  ncp ;
         double  tc ;
         char  answer ;  
              
        
         public   Ingredient ( String  name ,   String  units ,   float  amount ,   double  calories ,   double  totCal ){
    name  =  nameOfIngredient ;
    units  =  unitOfMeasurement ;
    amount  =  ingredientAmount ;
    calories  =  numberCaloriesPerCup ;
    totCal  =  totalCalories ;
    
   }

 
     Ingredient ()   {
         throw   new   UnsupportedOperationException ( "Not supported yet." );   //To change body of generated methods, choose Tools | Templates.
     }

    
        

     /**
     *  @return  the nameOfIngredient
     */
     public   String  getNameOfIngredient ()   {
                
         return  nameOfIngredient ;
     }

     /**
     * 
     */
     public   void  setNameOfIngredient ()   {
                
         System . out . println ( "Enter the name of the ingredient: " );
         this . nameOfIngredient  =   Validation . getString ();
        
     }

     /**
     *  @return  the unitOfMeasurement
     */
     public   String  getUnitOfMeasurement ()   {
         return  unitOfMeasurement ;
     }

     /**
     *
     */
     public   void  setUnitOfMeasurement ()   {
        
         System . out . println ( "Enter the unit of measurement used: " );
         this . unitOfMeasurement  =   Validation . getString ();
     }

   

     /**
     *  @return  the ingredientAmount
     */
     public   float  getIngredientAmount ()   {
         return  ingredientAmount ;
     }

     /**
     * 
     */
     public   void  setIngredientAmount ()   {
        
         System . out . println ( "How many "   +  unitOfMeasurement  +   " to use? " );
         this . ingredientAmount  =   Validation . getFloat ();
     }

     /**
     *  @return  the numberCaloriesPerCup
     */
     public   double  getNumberCaloriesPerCup ()   {
         return  numberCaloriesPerCup ;
     }

     /**
     * 
     */
     public   void  setNumberCaloriesPerCup ()   {
        
         System . out . println ( "How many calories per "   +  unitOfMeasurement  +   " of "   +  nameOfIngredient  +   "? " );
         this . numberCaloriesPerCup  =   Validation . getDouble ();
     }

     /**
     *  @return  the totalCalories
     */
     public   double  getTotalCalories ()   {
         return  totalCalories ;
     }

     /**
     * 
     */
     public   void  setTotalCalories ()   {
         this . totalCalories  =  numberCaloriesPerCup  *  ingredientAmount ;
     }

     void  setNameOfIngredient ( String  ingredientName )   {
         throw   new   UnsupportedOperationException ( "Not supported yet." );   //To change body of generated methods, choose Tools | Templates.
     }
        
    
  
    
    
               
        
        
   

   
   

        
    
}
    
   
    

recipe/RecipeManagerApp/src/recipemanagerapp/Recipe.java

recipe/RecipeManagerApp/src/recipemanagerapp/Recipe.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  recipemanagerapp ;
import  java . util . * ;
/**
 *
 *  @author  dewin
 */
public   class   Recipe   {

         // method for getting recipe for diffferent serving size. 
     private   static   void  changeServingSize ( String  recipeName ,   Recipe  recipeObj )   {
            
         // Ask user for serving size.
             System . out . println ( "What serving size would you like to see? " );
             int  serveSize  =   Validation . getInt ();
            
             // Gets the number to multiply by to get correct measurements. 
             int  numToMultiplyBy  =  serveSize  /  recipeObj . getServingSize ();
            
             // prints the recipe to the screen.
            System . out . println ( "Recipe for "   +  recipeName  +   " : Serving size = "   +  serveSize  +   " Total calories = "   +  recipeObj . getTotalRecipeCalories ()   *  numToMultiplyBy  );
           
             // uses for loop to print the full recipe.
          for ( int  i  =   0 ;  i  <  recipeObj . ingredientList . size ();  i ++ )   {
             System . out . println ( recipeObj . ingredientList . get ( i ). getIngredientAmount ()   *  numToMultiplyBy  +   " "   +  recipeObj . ingredientList . get ( i ). getUnitOfMeasurement ()   +   " of " +  recipeObj . ingredientList . get ( i ). getNameOfIngredient ()   +   " (Total calories for this ingredient is: "   +  recipeObj . ingredientList . get ( i ). getTotalCalories ()   *  numToMultiplyBy  +   ")"   );
         }

     }
    
     // method for printing the recipe.
     
        private   static   double  printRecipe (   String  recipeName ,   Recipe  recipeObj )   {
        
            System . out . println ( "Recipe for "   +  recipeName  +   " : Serving size = "   +  recipeObj . getServingSize ()   +   " Total calories = "   +  recipeObj . getTotalRecipeCalories ()   );
           
             // uses for loop to print the full recipe.
          for ( int  i  =   0 ;  i  <  recipeObj . ingredientList . size ();  i ++ )   {
             System . out . println ( recipeObj . ingredientList . get ( i ). getIngredientAmount ()   +   " "   +  recipeObj . ingredientList . get ( i ). getUnitOfMeasurement ()   +   " of " +  recipeObj . ingredientList . get ( i ). getNameOfIngredient ()   +   " (Total calories for this ingredient is: "   +  recipeObj . ingredientList . get ( i ). getTotalCalories ()   +   ")"   );
         }
         
          // Ask user if to get different serving size. uses while loop to keep asking until user is finished. 
              promptchangeServeSize ();
          double  changeServeSize  =   Validation . getNumber ();
          double  answer  =  changeServeSize ;
          while   ( changeServeSize  ==   1 )   {
         
             changeServingSize ( recipeObj . getRecipeName (),  recipeObj );
             
             promptchangeServeSize ();
            changeServeSize  =   Validation . getNumber ();
          }
         return  answer ;
         
           
     }
       
       
       
       
        // Asks user if to add ingredient of exit and print recipe.
         private   static   void  promptToAdd ()   {
         System . out . println ( "Press 1 to add an ingredient. Press any other number to print recipe and exit." );
        
     }
        
         // Asks user if to get different serving size.
         private   static   void  promptchangeServeSize ()   {
         System . out . println ( "\n"   +   "Press 1 to get recipe for different serving size. Press any other number to exit." );
        
     }
           // Asks user if to enter program and start new recipe.
         private   static   void  promptToStartNewRecipe ()   {
         System . out . println ( "\n"   +   "Press 1 to start a recipe. Press any other number to exit." );
        
     }
        
        
        
        
      // These are the class variables. 
      private   String  userName ;
      private   String  recipeName ;
      private   int  servingSize ;
      private   double  totalRecipeCalories ;
      private   ArrayList < Ingredient >  ingredientList  =   new   ArrayList <> ();
      private   ArrayList < Recipe >  recipeList  =   new   ArrayList <> ();
     
     
      // Program starts here.
     public   static   void  main ( String []  args ){
    
        
        
        
         // Welcome message.
         System . out . println ( "Welcome to my recipe manager application." );
        
        promptToStartNewRecipe ();
         int  enter  =   Validation . getInt ();
        
     while   ( enter  ==   1 )   {     
     // creating a recipe object to use. 
     Recipe  recipeObj  =   new   Recipe ();
     int  count  =   0 ;
    
    
     // used to set user name and recipe name.
    recipeObj . setUserName ();
    recipeObj . setRecipeName ();
   
    
    
    
     // ask user if to add ingredient or print recipe and exit.
    promptToAdd ();
     double  answer  =   Validation . getNumber ();
    
     //while loop to keep adding ingredients if user wants to  add more.
     while   ( answer  ==   1 )   {
         //creates new ingredient object each time to save in the ingredients list.
      Ingredient  ingredientObj  =   new   Ingredient ();
            
      // sets all of the variables. 
            ingredientObj . setNameOfIngredient ();
            ingredientObj . setUnitOfMeasurement ();
            ingredientObj . setIngredientAmount ();
            ingredientObj . setNumberCaloriesPerCup ();
            ingredientObj . setTotalCalories ();
            
             //stores ingredient variable in array list.
            recipeObj . ingredientList . add ( ingredientObj );
            
            
            
            promptToAdd ();
            answer  =   Validation . getNumber ();
            
            
       
       
     }
         // Asks for the serving size.
            recipeObj . setServingSize ();
                
         //calculates the total calories for the recipe.
        recipeObj . setTotalRecipeCalories ( recipeObj );
        
         // print method to print the full recipe.
       printRecipe ( recipeObj . getRecipeName (),  recipeObj );
     
       recipeObj . recipeList . add ( recipeObj );
       
       count ++ ;
       
        if   ( count  >=   2 )   {
         System . out . println ( "Which recipe would you like to see? " );
         String  recipeNameToSee  =   Validation . getString ();
        
        
         int  x  =  searchByName ( recipeObj ,  recipeNameToSee );
        
        printRecipeRequested ( x ,  recipeObj );
        }
       
       
     }    
       
          // program ends.  
         System . out . println ( "\n"   +   "Thanks for using this program. Bye." );
         
        

     }  
    
     public   static   int  searchByName ( Recipe  recipeObj ,   String  recipeNameToSee )   {
         for   ( int  i =   0 ;  i  <  recipeObj . recipeList . size ();  i ++ )   {
             if   ( recipeObj . recipeList . get ( i ). getRecipeName (). equalsIgnoreCase ( recipeNameToSee ))  
                 return  i ;
             }
         return   - 1 ;
         }
        
     private   static   void  printRecipeRequested ( int  x ,   Recipe  recipeObj )   {
    
         System . out . println ( "Recipe for "   +  recipeObj . recipeList . get ( x ). getRecipeName ()   +   " : Serving size = "   +  recipeObj . recipeList . get ( x ). getServingSize ()   +   " Total calories = "   +  recipeObj . recipeList . get ( x ). getTotalRecipeCalories ()   );
         
         for ( int  i  =   0 ;  i  <  recipeObj . ingredientList . size ();  i ++ ){
         System . out . println ( recipeObj . recipeList . get ( x ). ingredientList . get ( i ). getIngredientAmount ()   +   " "   +  recipeObj . recipeList . get ( x ). ingredientList . get ( i ). getUnitOfMeasurement ()   +   " of " +  recipeObj . recipeList . get ( x ). ingredientList . get ( i ). getNameOfIngredient ()   +   " (Total calories for this ingredient is: "   +  recipeObj . recipeList . get ( x ). ingredientList . get ( i ). getTotalCalories ()   +   ")"   );
     }
     }
    

     /**
     *  @return  the userName
     */
     public   String  getUserName ()   {
         return  userName ;
     }

     /**
     * sets the user name.
     */
     public   void  setUserName ()   {
         System . out . println ( "Please tell me your name. " );  
         this . userName  =   Validation . getString ();
     }

     /**
     *  @return  the recipeName
     */
     public   String  getRecipeName ()   {
         return  recipeName ;
     }

     /**
     * sets the recipe name
     */
     public   void  setRecipeName ()   {
         System . out . println ( "Ok "   +  userName  +   ". Please tell me the name of this recipe. " );
         this . recipeName  =   Validation . getString ();
     }

     /**
     *  @return  the servingSize
     */
     public   int  getServingSize ()   {
         return  servingSize ;
     }

     /** sets the serving size.
     */
     public   void  setServingSize ()   {
         System . out . println ( "What is the serving size for this recipe? " );
         this . servingSize  =   Validation . getInt ();
     }

     /**
     *  @return  the totalRecipeCalories
     */
     public   double  getTotalRecipeCalories ()   {
         return  totalRecipeCalories ;
     }

     /**
     * calculates the total calories.
     *  @param  recipeObj
     */
     public   void  setTotalRecipeCalories ( Recipe  recipeObj )   {
         double  tot  =   0 ;
         for ( int  i  =   0 ;  i  <  recipeObj . ingredientList . size ();  i ++ )   {
            tot  =  tot  +  recipeObj . ingredientList . get ( i ). getTotalCalories ();
         }
         this . totalRecipeCalories  =  tot ;
     }

     /**
     *  @return  the ingredientList
     */
     public   ArrayList < Ingredient >  getIngredientList ()   {
         return  ingredientList ;
     }

     /**
     *  @param  ingredientList the ingredientList to set
     */
     public   void  setIngredientList ( ArrayList < Ingredient >  ingredientList )   {
         this . ingredientList  =  ingredientList ;
     }

     /**
     *  @return  the RecipeList
     */
     public   ArrayList < Recipe >  getRecipeList ()   {
         return  recipeList ;
     }

     /**
     *  @param  RecipeList the RecipeList to set
     */
     public   void  setRecipeList ( ArrayList < Recipe >   RecipeList )   {
         this . recipeList  =   RecipeList ;
     }
    
    
    
    
    
    
    
    
    
    
     }

   
    
    

recipe/RecipeManagerApp/src/recipemanagerapp/Validation.java

recipe/RecipeManagerApp/src/recipemanagerapp/Validation.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  recipemanagerapp ;

import  java . util . Scanner ;

/**
 *
 *  @author  dewin
 */
public   class   Validation   {
    
     public   static   void  main  ( String []  args )   {
        
        getInt ();
        getNumber ();
        getDouble ();
        getString ();
        getFloat ();
     }
    
     static   int  getInt (){
    
             int  number  =   0 ;
         
       
             Scanner  scnr  =   new   Scanner ( System . in );
       
      
       
        //The following "if branch" uses the scanner method hasNextDouble() to
        //check to see if the input is a double.
       
        if   ( scnr . hasNextInt ())   {
          number  =  scnr . nextInt ();
           
        //NESTED BRANCH:
                         
              if   ( number  >=   1 )   {
                System . out . println ( number  +   " is a valid number." );
                }
            
              else   {
                System . out . println ( number  +   " is a not valid number!" );
                System . out . println ( "Please try again: " );
               number  =  scnr . nextInt ();
                }
            
              System . out . println ( "\n" );
         }    return  number ;
        
     }
    
    
    
    
     static   Double  getDouble (){
    
             double  numberCalories  =   0 ;
         
       
             Scanner  scnr  =   new   Scanner ( System . in );
       
      
       
        //The following "if branch" uses the scanner method hasNextDouble() to
        //check to see if the input is a double.
       
        if   ( scnr . hasNextDouble ())   {
           numberCalories  =  scnr . nextDouble ();
           
        //NESTED BRANCH:
                         
              if   ( numberCalories  >=   1 )   {
                System . out . println ( numberCalories  +   " is a valid number of calories!" );
                }
            
              else   {
                System . out . println ( numberCalories  +   " is a not valid number of calories!" );
                System . out . println ( "Please try again: " );
               numberCalories  =  scnr . nextDouble ();
                }
            
              System . out . println ( "\n" );
         }    return  numberCalories ;
        
     }
    
     static   Double  getNumber (){
    
             double  number  =   0 ;
         
       
             Scanner  scnr  =   new   Scanner ( System . in );
       
      
       
        //The following "if branch" uses the scanner method hasNextDouble() to
        //check to see if the input is a double.
       
        if   ( scnr . hasNextDouble ())   {
          number  =  scnr . nextDouble ();
           
        //NESTED BRANCH:
                         
              if   ( number  >=   1 )   {
                System . out . println ( " Ok " );
                }
            
              else   {
                System . out . println ( number  +   " is a not valid number!" );
                System . out . println ( "Please try again: " );
               number  =  scnr . nextDouble ();
                }
            
              System . out . println ( "\n" );
         }    return  number ;
        
     }
    
    
    
    
    
     // Used to validate a string.
    
      static   String  getString (){
         
           Scanner  scnr  =   new   Scanner ( System . in );
               
             String  name ;
            
        
            name  =  scnr . nextLine ();
        
        
             if   ( name . length ()   <   2   ||  name . trim (). isEmpty ())   {
        
                 System . out . println ( "You did not enter something properly." );
                 System . out . println ( "\n" );
                name  =   null ;
                 return  name ;
           
             }
        
              else   {
        
                 System . out . println ( "Thank you. "   +  name  +   " is valid."   );
                 System . out . println ( "\n" );
                
                
                 return  name ;
             }
                
          }  
       
      
     
       static   float  getFloat (){
    
        float  numberIng  =   0 ;
         
       
             Scanner  scnr  =   new   Scanner ( System . in );
       
      
       
        //The following "if branch" uses the scanner method hasNextDouble() to
        //check to see if the input is a double.
       
        if   ( scnr . hasNextDouble ())   {
           numberIng  =  scnr . nextFloat ();
           
        //NESTED BRANCH:
                         
              if   ( numberIng  >=   1 )   {
                System . out . println ( numberIng  +   " is a valid number!" );
                System . out . println ( "\n" );
                }
            
              else   {
                System . out . println ( numberIng  +   " is a not valid number!" );
                System . out . println ( "Please try again: " );
                System . out . println ( "\n" );
               numberIng  =  scnr . nextFloat ();
                }
            
               
             
                
     } return  numberIng ;
    }

}

recipe/RecipeManagerApp1/build.xml

Builds, tests, and runs the project RecipeManagerApp.

recipe/RecipeManagerApp1/build/classes/.netbeans_automatic_build

recipe/RecipeManagerApp1/build/classes/.netbeans_update_resources

recipe/RecipeManagerApp1/build/classes/recipemanagerapp/Ingredient.class

package recipemanagerapp;
public synchronized class Ingredient {
    private String nameOfIngredient;
    private String unitOfMeasurement;
    private float ingredientAmount;
    private double numberCaloriesPerCup;
    private double totalCalories;
    String noi;
    String uom;
    float ia;
    double ncp;
    double tc;
    char answer;
    public void Ingredient(String, String, float, double);
    void Ingredient();
    public String getNameOfIngredient();
    public void setNameOfIngredient();
    public String getUnitOfMeasurement();
    public void setUnitOfMeasurement();
    public float getIngredientAmount();
    public void setIngredientAmount();
    public double getNumberCaloriesPerCup();
    public void setNumberCaloriesPerCup();
    public double getTotalCalories();
    public void setTotalCalories();
    void setNameOfIngredient(String);
}

recipe/RecipeManagerApp1/build/classes/recipemanagerapp/Recipe.class

package recipemanagerapp;
public synchronized class Recipe {
    private String recipeName;
    private int servingSize;
    private double totalRecipeCalories;
    private Ingredient ingredientObj;
    private java.util.ArrayList recipeIngredients;
    public void Recipe();
    public void Recipe(String, int, java.util.ArrayList, double);
    public void printRecipe();
    public static void main(String[]);
    public String getRecipeName();
    public void setRecipeName(String);
    public int getServingSize();
    public void setServingSize(int);
    public double getTotalRecipeCalories();
    public void setTotalRecipeCalories(double);
    public Ingredient getIngredientObj();
    public void setIngredientObj(Ingredient);
    public java.util.ArrayList getRecipeIngredients();
    public void setRecipeIngredients(java.util.ArrayList);
}

recipe/RecipeManagerApp1/build/classes/recipemanagerapp/Validation.class

package recipemanagerapp;
public synchronized class Validation {
    public void Validation();
    public static void main(String[]);
    static int getInt();
    static Double getDouble();
    static Double getNumber();
    static String getString();
    static float getFloat();
}

recipe/RecipeManagerApp1/manifest.mf

Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build

recipe/RecipeManagerApp1/nbproject/build-impl.xml

Must set src.dir Must set test.src.dir Must set build.dir Must set dist.dir Must set build.classes.dir Must set dist.javadoc.dir Must set build.test.classes.dir Must set build.test.results.dir Must set build.classes.excludes Must set dist.jar Must set javac.includes No tests executed. Must set JVM to use for profiling in profiler.info.jvm Must set profiler agent JVM arguments in profiler.info.jvmargs.agent

recipe/RecipeManagerApp1/nbproject/genfiles.properties

build.xml.data.CRC32=4b492756 build.xml.script.CRC32=89537af3 [email protected] # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=4b492756 nbproject/build-impl.xml.script.CRC32=a77c180e nbproject/[email protected]

recipe/RecipeManagerApp1/nbproject/private/private.properties

compile.on.save=true user.properties.file=C:\\Users\\dewin\\AppData\\Roaming\\NetBeans\\8.2\\build.properties

recipe/RecipeManagerApp1/nbproject/private/private.xml

file:/C:/Users/dewin/Desktop/School/IT600/recipe/RecipeManagerApp1/src/recipemanagerapp/Recipe.java

recipe/RecipeManagerApp1/nbproject/project.properties

annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processor.options= annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: build.dir=build build.generated.dir=${build.dir}/generated build.generated.sources.dir=${build.dir}/generated-sources # Only compile against the classpath explicitly listed here: build.sysclasspath=ignore build.test.classes.dir=${build.dir}/test/classes build.test.results.dir=${build.dir}/test/results # Uncomment to specify the preferred debugger connection transport: #debug.transport=dt_socket debug.classpath=\ ${run.classpath} debug.test.classpath=\ ${run.test.classpath} # Files in build.classes.dir which should be excluded from distribution jar dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist dist.jar=${dist.dir}/RecipeManagerApp.jar dist.javadoc.dir=${dist.dir}/javadoc excludes= includes=** jar.compress=false javac.classpath= # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false javac.external.vm=true javac.processorpath=\ ${javac.classpath} javac.source=1.8 javac.target=1.8 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir} javac.test.processorpath=\ ${javac.test.classpath} javadoc.additionalparam= javadoc.author=false javadoc.encoding=${source.encoding} javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=false javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= main.class=recipemanagerapp.Recipe manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false platform.active=default_platform run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} # Space-separated list of JVM arguments used when running the project. # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. # To set system properties for unit tests define test-sys-prop.name=value: run.jvmargs= run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} source.encoding=UTF-8 src.dir=src test.src.dir=test

recipe/RecipeManagerApp1/nbproject/project.xml

org.netbeans.modules.java.j2seproject RecipeManagerApp

recipe/RecipeManagerApp1/src/recipemanagerapp/Ingredient.java

recipe/RecipeManagerApp1/src/recipemanagerapp/Ingredient.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  recipemanagerapp ;

/**
 *
 *  @author  gerrard.dewin_snhu
 */
public   class   Ingredient   {
    
      // These are the class variables.        
         private   String  nameOfIngredient ;
         private   String  unitOfMeasurement ;
         private   float  ingredientAmount ;
         private   double  numberCaloriesPerCup ;
         private   double  totalCalories ;
       
        
         String  noi ;
         String  uom ;         
         float  ia ;
         double  ncp ;
         double  tc ;
         char  answer ;  
              
        
         public   Ingredient ( String  name ,   String  units ,   float  amount ,   double  calories ){
    name  =  nameOfIngredient ;
    units  =  unitOfMeasurement ;
    amount  =  ingredientAmount ;
    calories  =  numberCaloriesPerCup ;
    totalCalories  =  numberCaloriesPerCup  *  ingredientAmount ;
    
   }

     Ingredient ()   {
         throw   new   UnsupportedOperationException ( "Not supported yet." );   //To change body of generated methods, choose Tools | Templates.
     }
        
        

     /**
     *  @return  the nameOfIngredient
     */
     public   String  getNameOfIngredient ()   {
                
         return  nameOfIngredient ;
     }

     /**
     * 
     */
     public   void  setNameOfIngredient ()   {
                
         System . out . println ( "Enter the name of the ingredient: " );
         this . nameOfIngredient  =   Validation . getString ();
        
     }

     /**
     *  @return  the unitOfMeasurement
     */
     public   String  getUnitOfMeasurement ()   {
         return  unitOfMeasurement ;
     }

     /**
     *
     */
     public   void  setUnitOfMeasurement ()   {
        
         System . out . println ( "Enter the unit of measurement used: " );
         this . unitOfMeasurement  =   Validation . getString ();
     }

   

     /**
     *  @return  the ingredientAmount
     */
     public   float  getIngredientAmount ()   {
         return  ingredientAmount ;
     }

     /**
     * 
     */
     public   void  setIngredientAmount ()   {
        
         System . out . println ( "How many "   +  unitOfMeasurement  +   " to use? " );
         this . ingredientAmount  =   Validation . getFloat ();
     }

     /**
     *  @return  the numberCaloriesPerCup
     */
     public   double  getNumberCaloriesPerCup ()   {
         return  numberCaloriesPerCup ;
     }

     /**
     * 
     */
     public   void  setNumberCaloriesPerCup ()   {
        
         System . out . println ( "How many calories per "   +  unitOfMeasurement  +   " of "   +  nameOfIngredient  +   "? " );
         this . numberCaloriesPerCup  =   Validation . getDouble ();
     }

     /**
     *  @return  the totalCalories
     */
     public   double  getTotalCalories ()   {
         return  totalCalories ;
     }

     /**
     * 
     */
     public   void  setTotalCalories ()   {
         this . totalCalories  =  numberCaloriesPerCup  *  ingredientAmount ;
     }

     void  setNameOfIngredient ( String  ingredientName )   {
         throw   new   UnsupportedOperationException ( "Not supported yet." );   //To change body of generated methods, choose Tools | Templates.
     }
        
    
  
    
    
               
        
        
   

   
   

        
    
}
    
   
    

recipe/RecipeManagerApp1/src/recipemanagerapp/Recipe.java

recipe/RecipeManagerApp1/src/recipemanagerapp/Recipe.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  recipemanagerapp ;
import  java . util . * ;
/**
 *
 *  @author  dewin
 */
public   class   Recipe   {

   
     /*// method for getting recipe for diffferent serving size. 
    private static void changeServingSize(String recipeName, Recipe recipeObj) {
            
        // Ask user for serving size.
            System.out.println("What serving size would you like to see? ");
            int serveSize = Validation.getInt();
            
            // Gets the number to multiply by to get correct measurements. 
            int numToMultiplyBy = serveSize / recipeObj.getServingSize();
            
            // prints the recipe to the screen.
           System.out.println("Recipe for " + recipeName + " : Serving size = " + serveSize + " Total calories = " + recipeObj.getTotalRecipeCalories() * numToMultiplyBy );
           
            // uses for loop to print the full recipe.
         for(int i = 0; i < recipeObj.ingredientList.size(); i++) {
            System.out.println(recipeObj.ingredientList.get(i).getIngredientAmount() * numToMultiplyBy + " " + recipeObj.ingredientList.get(i).getUnitOfMeasurement() + " of "+ recipeObj.ingredientList.get(i).getNameOfIngredient() + " (Total calories for this ingredient is: " + recipeObj.ingredientList.get(i).getTotalCalories() * numToMultiplyBy + ")" );
        }

    }
    
    // method for printing the recipe.
     
       private static void printRecipe(String recipeName, Recipe recipeObj) {
        
           System.out.println("Recipe for " + recipeName + " : Serving size = " + recipeObj.getServingSize() + " Total calories = " + recipeObj.getTotalRecipeCalories() );
           
            // uses for loop to print the full recipe.
         for(int i = 0; i < recipeObj.ingredientList.size(); i++) {
            System.out.println(recipeObj.ingredientList.get(i).getIngredientAmount() + " " + recipeObj.ingredientList.get(i).getUnitOfMeasurement() + " of "+ recipeObj.ingredientList.get(i).getNameOfIngredient() + " (Total calories for this ingredient is: " + recipeObj.ingredientList.get(i).getTotalCalories() + ")" );
        }
         
         // Ask user if to get different serving size. uses while loop to keep asking until user is finished. 
         
         
        
         
           
    }
       
       
       
       
       // Asks user if to add ingredient of exit and print recipe.
        private static void promptToAdd() {
        System.out.println("Press y to add an ingredient. Press any other letter to print recipe and exit.");
        
    }
        
        // Asks user if to get different serving size.
        private static void promptchangeServeSize() {
        System.out.println("\n" + "Press 1 to get recipe for different serving size. Press any other number to exit.");
        
    }
          // Asks user if to enter program and start new recipe.
        private static void promptToStartNewRecipe() {
        System.out.println("\n" + "Press y to start a recipe. Press any other letter to exit.");
        
    }
        
       **/  
        
        
      // These are the class variables. 
      //private String userName;
      private   String  recipeName ;
      private   int  servingSize ;
      private   double  totalRecipeCalories ;
      private   Ingredient  ingredientObj  =   new   Ingredient ();
      private   ArrayList < Ingredient >  recipeIngredients  =   new   ArrayList <> ();
     // private ArrayList<Recipe> recipeList = new ArrayList<>();
     
     
     
       public   Recipe ()   {
         this . recipeName  =   "" ;
         this . servingSize  =   0 ;   //<--- assignment value with appropriate data type
         this . recipeIngredients . add ( ingredientObj );   //<-- assignment value for empty ArrayList
         this . totalRecipeCalories  =   0 ;
        
     }
      
      
       public   Recipe ( String  recipeName ,   int  servingSize ,  
         ArrayList < Ingredient >  recipeIngredients ,   double  totalRecipeCalories )  
     //<-- use appropriate data type for the ArrayList and the servings arguments
     {
         this . recipeName  =  recipeName ;
         this . servingSize  =  servingSize ;
         this . recipeIngredients  =  recipeIngredients ;
         this . totalRecipeCalories  =  totalRecipeCalories ;
     }
     
     
      public   void  printRecipe ()   {
        
         int  singleServingCalories  =   ( int ) getTotalRecipeCalories ()   /  getServingSize ();
        
         /**
         * Declare an int variable singleServingCalories.
         * Assign singleServingCalories to
         * the totalRecipeCalories divided by the servings
         * 
         */
         
         System . out . println ( "Recipe: "   +  getRecipeName ());
        
         System . out . println ( "Serves: "   +  getServingSize ());
         System . out . println ( "Ingredients: " );
         for ( int  i  =   0 ;  i  <  getRecipeIngredients (). size ();  i ++ ){
             System . out . println ( getRecipeIngredients (). get ( i ). getIngredientAmount ()   +   " "   +  getRecipeIngredients (). get ( i ). getUnitOfMeasurement ()   +   " of " +  getRecipeIngredients (). get ( i ). getNameOfIngredient ()   +   " (Total calories for this ingredient is: "   +  getRecipeIngredients (). get ( i ). getTotalCalories ()   +   ")" );
         }
         System . out . println ( "Each serving has "   +  singleServingCalories  +   " Calories."   );
        
        
         /**
         * Print the following recipe information:
         *      Recipe: <<recipeName>>
         *      Serves: <<servings>>
         *      Ingredients:
         *      <<Ingredient1>>
         *      <<Ingredient2>>
         *      ...
         *      <<Last Ingredient>>
         *      
         *      Each serving has <<singleServingCalories>> Calories.
         *
         *      HINT --> Use a for loop to iterate through the ingredients   
         */
     }
     
      
       public   static   void  main ( String []  args )   {
         double  totalRecipeCalories  =   0.0 ;
         ArrayList   < Ingredient >  recipeIngredients  =   new   ArrayList ();
        
         boolean  addMoreIngredients  =   true ;
        
     
        
         System . out . println ( "Please enter the recipe name: " );
         String  recipeName  =   Validation . getString ();
        
         System . out . println ( "Please enter the number of servings: " );
         //correct data type & Scanner assignment method for servings variable
         int  servingSize  =   Validation . getInt ();
        
                
         do   {
            
           
             System . out . println ( "Please enter the ingredient name or type end if you are finished entering ingredients: " );
            
             String  ingredientName  =   Validation . getString ();
            
            
             if   ( ingredientName . toLowerCase (). equals ( "end" ))   {
                addMoreIngredients  =   false ;
             }   else   {
                
         
                 System . out . println ( "Please enter the unit of measurement: " );
                
                 String  unitOfMeasurement  =   Validation . getString ();
                
                
                 System . out . println ( "Please enter the ingredient amount: " );
                
                 float  ingredientAmount  =   Validation . getFloat ();
            
                
                 System . out . println (   "Please enter the ingredient Calories: " );
                
                 int  ingredientCalories  =   Validation . getInt ();
                
                 /**
                * Add the total Calories from this ingredient
                *  (ingredientCalories * ingredientAmount)
                * to the totalRecipeCalories
                * 
                */
                
            recipeIngredients . add ( new   Ingredient ( ingredientName , unitOfMeasurement , ingredientAmount , ingredientCalories ));
             }
            
           
           
        }   while   ( addMoreIngredients  ==   true )   ;
        
        
         Recipe  recipe1  =   new   Recipe ( recipeName ,  servingSize ,  recipeIngredients ,  totalRecipeCalories );      
        recipe1 . printRecipe ();
     }

      
      
      
      
      
      
     /**
     *  @return  the recipeName
     */
     public   String  getRecipeName ()   {
         return  recipeName ;
     }

     /**
     *  @param  recipeName the recipeName to set
     */
     public   void  setRecipeName ( String  recipeName )   {
         this . recipeName  =  recipeName ;
     }

     /**
     *  @return  the servingSize
     */
     public   int  getServingSize ()   {
         return  servingSize ;
     }

     /**
     *  @param  servingSize the servingSize to set
     */
     public   void  setServingSize ( int  servingSize )   {
         this . servingSize  =  servingSize ;
     }

     /**
     *  @return  the totalRecipeCalories
     */
     public   double  getTotalRecipeCalories ()   {
         return  totalRecipeCalories ;
     }

     /**
     *  @param  totalRecipeCalories the totalRecipeCalories to set
     */
     public   void  setTotalRecipeCalories ( double  totalRecipeCalories )   {
         this . totalRecipeCalories  =  totalRecipeCalories ;
     }

     /**
     *  @return  the ingredientObj
     */
     public   Ingredient  getIngredientObj ()   {
         return  ingredientObj ;
     }

     /**
     *  @param  ingredientObj the ingredientObj to set
     */
     public   void  setIngredientObj ( Ingredient  ingredientObj )   {
         this . ingredientObj  =  ingredientObj ;
     }

     /**
     *  @return  the recipeIngredients
     */
     public   ArrayList < Ingredient >  getRecipeIngredients ()   {
         return  recipeIngredients ;
     }

     /**
     *  @param  recipeIngredients the recipeIngredients to set
     */
     public   void  setRecipeIngredients ( ArrayList < Ingredient >  recipeIngredients )   {
         this . recipeIngredients  =  recipeIngredients ;
     }
      
      
      
      
      
      
     
     
     
     
     
     
     
     
     
     
     
     
      /*
     
     
     
     // Program starts here.
    public static void main(String[] args){
    
        
        Scanner scnr = new Scanner(System.in);
        
        // Welcome message.
        System.out.println("Welcome to my recipe manager application.");
        
        promptToStartNewRecipe();
        char enter = scnr.next().charAt(0);
        
    while ((enter == 'Y') || (enter == 'y')) {    
    // creating a recipe object to use. 
    Recipe recipeObj = new Recipe();
    int count = 1;
    
    
    // used to set user name and recipe name.
    recipeObj.setUserName();
    recipeObj.setRecipeName();
   
    
    
    
    // ask user if to add ingredient or print recipe and exit.
    promptToAdd();
    
    char answer = scnr.next().charAt(0);
    
    //while loop to keep adding ingredients if user wants to  add more.
    while ((answer == 'Y') ||(answer == 'y')) {
        //creates new ingredient object each time to save in the ingredients list.
     Ingredient ingredientObj = new Ingredient();
            
     // sets all of the variables. 
            ingredientObj.setNameOfIngredient();
            ingredientObj.setUnitOfMeasurement();
            ingredientObj.setIngredientAmount();
            ingredientObj.setNumberCaloriesPerCup();
            ingredientObj.setTotalCalories();
            
            //stores ingredient variable in array list.
            recipeObj.ingredientList.add(ingredientObj);
            
            
            
            promptToAdd();
            answer = scnr.next().charAt(0);
            
            System.out.print("Would you like to enter another class? ");
            enter = scnr.next().charAt(0);
             
       
    }
    
        
    
    
        // Asks for the serving size.
            recipeObj.setServingSize();
                
        //calculates the total calories for the recipe.
        recipeObj.setTotalRecipeCalories(recipeObj);
        
        // print method to print the full recipe.
       printRecipe(recipeObj.getRecipeName(), recipeObj);
     
       recipeObj.recipeList.add(recipeObj);
       
       // Ask user if to get different serving size. uses while loop to keep asking until user is finished. 
              promptchangeServeSize();
         int changeServeSize = scnr.nextInt();
         
         if (changeServeSize == 1) {
         
             changeServingSize(recipeObj.getRecipeName(), recipeObj);
             
             promptchangeServeSize();
            changeServeSize = scnr.nextInt();
         }
         else {
       
       count++;
         }
       if (count >= 2) {
        System.out.println("Which recipe would you like to see? ");
        String recipeNameToSee = Validation.getString();
        
        
        int x = searchByName(recipeObj, recipeNameToSee);
        
        printRecipeRequested(x, recipeObj);
       }
       
       
       
    }   
       
         // program ends.  
        System.out.println("\n" + "Thanks for using this program. Bye.");
         
        

    } 
    
    public static int searchByName(Recipe recipeObj, String recipeNameToSee) {
        for (int i= 0; i < recipeObj.recipeList.size(); i++) {
            if (recipeObj.recipeList.get(i).getRecipeName().equalsIgnoreCase(recipeNameToSee)) 
                return i;
            }
        return -1;
        }
        
    private static void printRecipeRequested(int x, Recipe recipeObj) {
    
        System.out.println("Recipe for " + recipeObj.recipeList.get(x).getRecipeName() + " : Serving size = " + recipeObj.recipeList.get(x).getServingSize() + " Total calories = " + recipeObj.recipeList.get(x).getTotalRecipeCalories() );
         
        for(int i = 0; i < recipeObj.ingredientList.size(); i++){
        System.out.println(recipeObj.recipeList.get(x).ingredientList.get(i).getIngredientAmount() + " " + recipeObj.recipeList.get(x).ingredientList.get(i).getUnitOfMeasurement() + " of "+ recipeObj.recipeList.get(x).ingredientList.get(i).getNameOfIngredient() + " (Total calories for this ingredient is: " + recipeObj.recipeList.get(x).ingredientList.get(i).getTotalCalories() + ")" );
    }
    }
    
**/
      
       /**
    /**
     *  @return  the userName
     */ /*
    public String getUserName() {
        return userName;
    }

    /**
     * sets the user name.
     *//*
    public void setUserName() {
        System.out.println("Please tell me your name. "); 
        this.userName = Validation.getString();
    }

    /**
     * @return the recipeName
     *//*
    public String getRecipeName() {
        return recipeName;
    }

    /**
     * sets the recipe name
     *//*
    public void setRecipeName() {
        System.out.println("Ok " + userName + ". Please tell me the name of this recipe. ");
        this.recipeName = Validation.getString();
    }

    /**
     * @return the servingSize
     *//*
    public int getServingSize() {
        return servingSize;
    }

    /** sets the serving size.
     *//*
    public void setServingSize() {
        System.out.println("What is the serving size for this recipe? ");
        this.servingSize = Validation.getInt();
    }

    /**
     * @return the totalRecipeCalories
     *//*
    public double getTotalRecipeCalories() {
        return totalRecipeCalories;
    }

    /**
     * calculates the total calories.
     * @param recipeObj
     */
     /*
    public void setTotalRecipeCalories(Recipe recipeObj) {
        double tot = 0;
        for(int i = 0; i < recipeObj.ingredientList.size(); i++) {
            tot = tot + recipeObj.ingredientList.get(i).getTotalCalories();
        }
        this.totalRecipeCalories = tot;
    }

    /**
     * @return the ingredientList
     */
     /*
    public ArrayList<Ingredient> getIngredientList() {
        return ingredientList;
    }

    /**
     * @param ingredientList the ingredientList to set
     */
     /*
    public void setIngredientList(ArrayList<Ingredient> ingredientList) {
        this.ingredientList = ingredientList;
    }

    /**
     * @return the RecipeList
     */
     /*
    public ArrayList<Recipe> getRecipeList() {
        return recipeList;
    }

    /**
     * @param RecipeList the RecipeList to set
     */
     /**
    public void setRecipeList(ArrayList<Recipe> RecipeList) {
        this.recipeList = RecipeList;
    }
    
    **/
    
    
    
    
    
    
    
    
     }

   
    
    

recipe/RecipeManagerApp1/src/recipemanagerapp/Validation.java

recipe/RecipeManagerApp1/src/recipemanagerapp/Validation.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  recipemanagerapp ;

import  java . util . Scanner ;

/**
 *
 *  @author  dewin
 */
public   class   Validation   {
    
     public   static   void  main  ( String []  args )   {
        
        getInt ();
        getNumber ();
        getDouble ();
        getString ();
        getFloat ();
     }
    
     static   int  getInt (){
    
             int  number  =   0 ;
         
       
             Scanner  scnr  =   new   Scanner ( System . in );
       
      
       
        //The following "if branch" uses the scanner method hasNextDouble() to
        //check to see if the input is a double.
       
        if   ( scnr . hasNextInt ())   {
          number  =  scnr . nextInt ();
           
        //NESTED BRANCH:
                         
              if   ( number  >=   1 )   {
                System . out . println ( number  +   " is a valid number." );
                }
            
              else   {
                System . out . println ( number  +   " is a not valid number!" );
                System . out . println ( "Please try again: " );
               number  =  scnr . nextInt ();
                }
            
              System . out . println ( "\n" );
         }    return  number ;
        
     }
    
    
    
    
     static   Double  getDouble (){
    
             double  numberCalories  =   0 ;
         
       
             Scanner  scnr  =   new   Scanner ( System . in );
       
      
       
        //The following "if branch" uses the scanner method hasNextDouble() to
        //check to see if the input is a double.
       
        if   ( scnr . hasNextDouble ())   {
           numberCalories  =  scnr . nextDouble ();
           
        //NESTED BRANCH:
                         
              if   ( numberCalories  >=   1 )   {
                System . out . println ( numberCalories  +   " is a valid number of calories!" );
                }
            
              else   {
                System . out . println ( numberCalories  +   " is a not valid number of calories!" );
                System . out . println ( "Please try again: " );
               numberCalories  =  scnr . nextDouble ();
                }
            
              System . out . println ( "\n" );
         }    return  numberCalories ;
        
     }
    
     static   Double  getNumber (){
    
             double  number  =   0 ;
         
       
             Scanner  scnr  =   new   Scanner ( System . in );
       
      
       
        //The following "if branch" uses the scanner method hasNextDouble() to
        //check to see if the input is a double.
       
        if   ( scnr . hasNextDouble ())   {
          number  =  scnr . nextDouble ();
           
        //NESTED BRANCH:
                         
              if   ( number  >=   1 )   {
                System . out . println ( " Ok " );
                }
            
              else   {
                System . out . println ( number  +   " is a not valid number!" );
                System . out . println ( "Please try again: " );
               number  =  scnr . nextDouble ();
                }
            
              System . out . println ( "\n" );
         }    return  number ;
        
     }
    
    
    
    
    
     // Used to validate a string.
    
      static   String  getString (){
         
           Scanner  scnr  =   new   Scanner ( System . in );
               
             String  name ;
            
        
            name  =  scnr . nextLine ();
        
        
             if   ( name . length ()   <   2   ||  name . trim (). isEmpty ())   {
        
                 System . out . println ( "You did not enter something properly." );
                 System . out . println ( "\n" );
                name  =   null ;
                 return  name ;
           
             }
        
              else   {
        
                 System . out . println ( "Thank you. "   +  name  +   " is valid."   );
                 System . out . println ( "\n" );
                
                
                 return  name ;
             }
                
          }  
       
      
     
       static   float  getFloat (){
    
        float  numberIng  =   0 ;
         
       
             Scanner  scnr  =   new   Scanner ( System . in );
       
      
       
        //The following "if branch" uses the scanner method hasNextDouble() to
        //check to see if the input is a double.
       
        if   ( scnr . hasNextDouble ())   {
           numberIng  =  scnr . nextFloat ();
           
        //NESTED BRANCH:
                         
              if   ( numberIng  >=   1 )   {
                System . out . println ( numberIng  +   " is a valid number!" );
                System . out . println ( "\n" );
                }
            
              else   {
                System . out . println ( numberIng  +   " is a not valid number!" );
                System . out . println ( "Please try again: " );
                System . out . println ( "\n" );
               numberIng  =  scnr . nextFloat ();
                }
            
               
             
                
     } return  numberIng ;
    }

}

recipe/RecipeManagerApp3/manifest.mf

Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build

recipe/RecipeManagerApp3/src/recipemanagerapp/Ingredient.java

recipe/RecipeManagerApp3/src/recipemanagerapp/Ingredient.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  recipemanagerapp ;

/*import java.util.*;*/

/**
 *
 *  @author  gerrard.dewin_snhu
 */
public   class   Ingredient   {
    
    
     // Variables the class will use. (Arrays to hold multiple values)        
         private   String  nameOfIngredient ;
         private   String  unitOfMeasurement ;
         private   float  ingredientAmount ;
         private   double  numberCalories ;
         private   double  totalCalories ;
    
    
     // Variables the class will use. 
     Ingredient   (   String  noi ,    String  uom ,   float  ia ,   double  ncp ,   double  tc ){
    
        nameOfIngredient  =  noi ;
        unitOfMeasurement  =  uom ;
        ingredientAmount  =  ia ;
        numberCalories  =  ncp ;  
        totalCalories  =  tc ;
    
     }

     Ingredient ()   {
         throw   new   UnsupportedOperationException ( "Not supported yet." );   //To change body of generated methods, choose Tools | Templates.
     }
    
    
    
         //calculates total calories.
     public   double  getTotalCalories  (){
             return  ingredientAmount  *  numberCalories ;
     }

    
    
    
         //promts the user to enter data.
     public   void  promptEnterRecipeName  ()   {
    
         System . out . println ( "Enter the recipe name: " );
     }
     public   void  promptEnterIngredName  ()   {
    
         System . out . println ( "Enter the ingredient name: " );
     }
      public   void  promptEnterUnitOfMeasure  ()   {
    
         System . out . println ( "Enter the unit of measurement: " );
     }
    
      public   void  promptEnterIngredAmount  ()   {
    
         System . out . println ( "Enter the ingredient amount: " );
     }
       public   void  promptEnterCalorie  ()   {
    
         System . out . println ( "Enter the calories per unit of measurement: " );
     }
      public   void  promptAddMoreIngred  ()   {
    
         System . out . println ( " Would you like to add more ingredients to this recipe: " );
     }
    

    /* public static void main(String[] args) {
     
   
    }**/
    
    
    
    

     /**
     *  @return  the nameOfIngredient
     */
     public   String  getNameOfIngredient ()   {
         return  nameOfIngredient ;
     }

     /**
     *  @param  nameOfIngredient the nameOfIngredient to set
     */
     public   void  setNameOfIngredient ( String  nameOfIngredient )   {
         this . nameOfIngredient  =  nameOfIngredient ;
     }

    
    
    
    
    
     /**
     *  @return  the unitOfMeasurement
     */
     public   String  getUnitOfMeasurement ()   {
         return  unitOfMeasurement ;
     }

     /**
     *  @param  unitOfMeasurement the unitOfMeasurement to set
     */
     public   void  setUnitOfMeasurement ( String  unitOfMeasurement )   {
         this . unitOfMeasurement  =  unitOfMeasurement ;
     }

    
    
    
    
    
     /**
     *  @return  the ingredientAmount
     */
     public   float  getIngredientAmount ()   {
         return  ingredientAmount ;
     }

     /**
     *  @param  ingredientAmount the ingredientAmount to set
     */
     public   void  setIngredientAmount ( float  ingredientAmount )   {
         this . ingredientAmount  =  ingredientAmount ;
     }

    
    
    
    
     /**
     *  @return  the numberCaloriesPerCup
     */
     public   double  getNumberCalories ()   {
         return  numberCalories ;
     }

     /**
     *  @param  numberCaloriesPerCup the numberCaloriesPerCup to set
     */
     public   void  setNumberCalories ( double  numberCaloriesPerCup )   {
         this . numberCalories  =  numberCaloriesPerCup ;
     }

    
    
    
     /**
     *  @param  totalCalories the totalCalories to set
     */
     public   void  setTotalCalories ( double  totalCalories )   {
         this . totalCalories  =  totalCalories ;
     }

    
}
    

    

recipe/RecipeManagerApp3/src/recipemanagerapp/Recipe.java

recipe/RecipeManagerApp3/src/recipemanagerapp/Recipe.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  recipemanagerapp ;
import  java . util . * ;
/**
 *
 *  @author  dewin
 */
public   class   Recipe   {
    
     private   String  recipeName ;
     private   int  servings ;
     private   ArrayList < Ingredient >  recipeIngredients  =   new   ArrayList <> ();
     private   double  totalRecipeCalories ;
    
    
    
     public   Recipe ( String  recipeName1 ,   int  servings1 ,   ArrayList < Ingredient >  recipeIngredients1 ,   double  totalRecipeCalories1 )   {
         this . recipeName  =   "" ;
         this . servings  =   0 ;  
         this . recipeIngredients  =   new   ArrayList <> ();  
         this . totalRecipeCalories  =   0.0 ;
     }
    
          public   void  printRecipe ()   {
        
         int  singleServingCalories  =   ( int ) totalRecipeCalories  /  servings ;
        
        
         
         System . out . println ( "Recipe: "   +  recipeName );
         System . out . println ( "Serves: "   +  servings );
         System . out . println ( "Ingredients: " );
        
         for   ( int  i  =   0 ;  i  <  recipeIngredients . size ();  i ++ )   {
             System . out . println ( recipeIngredients . get ( i ));
         }
        
         System . out . println ( "Each serving has: "   +  singleServingCalories  +   " Calories." );
        
        
        
         /**
         * Print the following recipe information:
         *      Recipe: <<recipeName>>
         *      Serves: <<serviServes:ngs>>
         *      Ingredients:
         *      <<Ingredient1>>
         *      <<Ingredient2>>
         *      ...
         *      <<Last Ingredient>>
         *      
         *      Each serving has <<singleServingCalories>> Calories.
         *
         *      HINT --> Use a for loop to iterate through the ingredients   
         */
     }
    
    
    
    
    
    
    
    
    
    
     public   static   void  main ( String []  args )   {
     
          double  totalRecipeCalories  =   0.0 ;
         ArrayList   < Ingredient >  recipeIngredients  =   new   ArrayList ();
         boolean  addMoreIngredients  =   true ;
        
       
        
         Scanner  scnr  =   new   Scanner ( System . in );
        
         System . out . println ( "Please enter the recipe name: " );
         String  recipeName  =  scnr . nextLine ();
        
         System . out . println ( "Please enter the number of servings: " );
         //correct data type & Scanner assignment method for servings variable
         int  servings  =  scnr . nextInt ();
        
         String  ingredientName ;
        
          do   {
             
               Ingredient  ingredientobj  =   new   Ingredient ();
              
             System . out . println ( "Please enter the ingredient name or type end if you are finished entering ingredients: " );
            ingredientName  =  scnr . next ();
            
             if   ( ingredientName . toLowerCase (). equals ( "end" ))   {
                addMoreIngredients  =   false ;
             }   else   {
                
                
                
                ingredientobj . setNameOfIngredient ( ingredientName );
                
                
                
                recipeIngredients . add ( ingredientobj );
             /**
            * Add the ingredient name to recipeIngredients
            * 
            */
        
                 System . out . println ( "Please enter the unit of measurement: " );
                 String  unitOfMeasurement  =  scnr . nextLine ();
                ingredientobj . setUnitOfMeasurement ( unitOfMeasurement );
            
                 System . out . println ( "Please enter the ingredient amount: " );
                 float  ingredientAmount  =  scnr . nextFloat ();
                ingredientobj . setIngredientAmount ( ingredientAmount );
                
            
                 System . out . println ( "Please enter the ingredient Calories: " );
                 int  ingredientCalories  =  scnr . nextInt ();
                ingredientobj . setNumberCalories ( totalRecipeCalories );
                
                totalRecipeCalories  =   ( ingredientCalories  *  ingredientAmount );
                ingredientobj . setTotalCalories ( totalRecipeCalories );
                
               
             recipeIngredients . add ( ingredientobj );
             
             }
           
        }   while   ( ! ingredientName . toLowerCase (). equals ( "end" ))   ;
        
         Recipe  recipeOne  =   new   Recipe ( recipeName ,  servings ,  recipeIngredients ,  totalRecipeCalories );
        recipeOne . printRecipe ();
        
        
        
        
        
        
    
    
    
      
     }

     /**
     *  @return  the recipeName
     */
     public   String  getRecipeName ()   {
         return  recipeName ;
     }

     /**
     *  @param  recipeName the recipeName to set
     */
     public   void  setRecipeName ( String  recipeName )   {
         this . recipeName  =  recipeName ;
     }

     /**
     *  @return  the servings
     */
     public   int  getServings ()   {
         return  servings ;
     }

     /**
     *  @param  servings the servings to set
     */
     public   void  setServings ( int  servings )   {
         this . servings  =  servings ;
     }

     /**
     *  @return  the recipeIngredients
     */
     public   ArrayList < Ingredient >  getRecipeIngredients ()   {
         return  recipeIngredients ;
     }

     /**
     *  @param  recipeIngredients the recipeIngredients to set
     */
     public   void  setRecipeIngredients ( ArrayList < Ingredient >  recipeIngredients )   {
         this . recipeIngredients  =  recipeIngredients ;
     }

     /**
     *  @return  the totalRecipeCalories
     */
     public   double  getTotalRecipeCalories ()   {
         return  totalRecipeCalories ;
     }

     /**
     *  @param  totalRecipeCalories the totalRecipeCalories to set
     */
     public   void  setTotalRecipeCalories ( double  totalRecipeCalories )   {
         this . totalRecipeCalories  =  totalRecipeCalories ;
     }
    
    
    
}

recipe/RecipeManagerApp3/src/recipemanagerapp/Validation.java

recipe/RecipeManagerApp3/src/recipemanagerapp/Validation.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package  recipemanagerapp ;

import  java . util . Scanner ;

/**
 *
 *  @author  dewin
 */
public   class   Validation   {
    
     public   static   void  main  ( String []  args )   {
        
        getDouble ();
        getString ();
        getFloat ();
     }
    
    
    
    
     static   Double  getDouble (){
    
             double  numberCalories  =   0 ;
         
       
             Scanner  scnr  =   new   Scanner ( System . in );
       
      
       
        //The following "if branch" uses the scanner method hasNextDouble() to
        //check to see if the input is a double.
       
        if   ( scnr . hasNextDouble ())   {
           numberCalories  =  scnr . nextDouble ();
           
        //NESTED BRANCH:
                         
              if   ( numberCalories  >=   1 )   {
                System . out . println ( numberCalories  +   " is a valid number of calories!" );
                }
            
              else   {
                System . out . println ( numberCalories  +   " is a not valid number of calories!" );
                System . out . println ( "Please try again: " );
               numberCalories  =  scnr . nextDouble ();
                }
            
              System . out . println ( "\n" );
         }    return  numberCalories ;
        
     }
    
    
    
    
    
     // Used to validate a string.
    
      static   String  getString (){
         
           Scanner  scnr  =   new   Scanner ( System . in );
               
             String  name ;
            
        
            name  =  scnr . nextLine ();
        
        
             if   ( name . length ()   <   2   ||  name . trim (). isEmpty ())   {
        
                 System . out . println ( "You did not enter something properly." );
                 System . out . println ( "\n" );
                name  =   null ;
                 return  name ;
           
             }
        
              else   {
        
                 System . out . println ( "Thank you. "   +  name  +   " is valid."   );
                 System . out . println ( "\n" );
                
                
                 return  name ;
             }
                
          }  
       
      
     
       static   float  getFloat (){
    
        float  numberIng  =   0 ;
         
       
             Scanner  scnr  =   new   Scanner ( System . in );
       
      
       
        //The following "if branch" uses the scanner method hasNextDouble() to
        //check to see if the input is a double.
       
        if   ( scnr . hasNextDouble ())   {
           numberIng  =  scnr . nextFloat ();
           
        //NESTED BRANCH:
                         
              if   ( numberIng  >=   1 )   {
                System . out . println ( numberIng  +   " is a valid number!" );
                System . out . println ( "\n" );
                }
            
              else   {
                System . out . println ( numberIng  +   " is a not valid number!" );
                System . out . println ( "Please try again: " );
                System . out . println ( "\n" );
               numberIng  =  scnr . nextFloat ();
                }
            
               
             
                
     } return  numberIng ;
    }

}