Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

why wont this class print? package holidaycelebrations; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Scanner; /** * * @author */ public class HolidayCelebrations { public

why wont this class print?

package holidaycelebrations; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Scanner;

/** * * @author */ public class HolidayCelebrations {

public static void main(String[] args) throws IOException { ArrayList myFamilyTraditions = createTraditions(); celebrateHolidays(myFamilyTraditions); } public static ArrayList createTraditions() throws IOException { //arrayList that hold the objects of granparents,parents and children ArrayList myFamilyTraditions = new ArrayList<>(); File aFile = new File("holidays.txt"); Scanner inFile = new Scanner(aFile); //variables to hold data from file GrandparentsTradition aGrandParent; ParentsTradition aParent; ChildrenTradition aChild; String typeRecord; //grandparent String holidayName; String holidaySeason; String timeOfDayCelebration; String mainDishName; int numberOfSideDishes; String locationOfGathering; double costOfMeal; String mealSource; //parent int numberInvited ; String traditionalDessert ; String traditionalDrink ; double costPerDessert ; double costPerDrink ; //children String holidayGame ; String holidayStorybook ; String holidayMovie ; double costOfMovie ; while (inFile.hasNext()) { typeRecord=inFile.nextLine(); if (typeRecord.equals("g")){ holidayName=inFile.nextLine(); holidaySeason=inFile.nextLine(); timeOfDayCelebration=inFile.nextLine(); mainDishName=inFile.nextLine(); numberOfSideDishes = inFile.nextInt(); locationOfGathering=inFile.nextLine(); costOfMeal=inFile.nextDouble(); mealSource=inFile.nextLine(); aGrandParent = new GrandparentsTradition(holidayName,holidaySeason,timeOfDayCelebration,mainDishName, numberOfSideDishes,locationOfGathering,costOfMeal,mealSource); myFamilyTraditions.add(aGrandParent); } else if (typeRecord.equals("p")){ holidayName=inFile.nextLine(); holidaySeason=inFile.nextLine(); timeOfDayCelebration=inFile.nextLine(); mainDishName=inFile.nextLine(); numberOfSideDishes = inFile.nextInt(); locationOfGathering=inFile.nextLine(); costOfMeal=inFile.nextDouble(); mealSource=inFile.nextLine(); numberInvited=inFile.nextInt(); traditionalDessert=inFile.nextLine(); traditionalDrink=inFile.nextLine(); costPerDessert=inFile.nextDouble(); costPerDrink=inFile.nextDouble(); aParent= new ParentsTradition(holidayName,holidaySeason,timeOfDayCelebration,mainDishName,numberOfSideDishes,locationOfGathering,costOfMeal,mealSource,numberInvited,traditionalDessert, traditionalDrink,costPerDessert,costPerDrink); myFamilyTraditions.add(aParent); } else if (typeRecord.equals("c")){ holidayName=inFile.nextLine(); holidaySeason=inFile.nextLine(); timeOfDayCelebration=inFile.nextLine(); mainDishName=inFile.nextLine(); numberOfSideDishes = inFile.nextInt(); locationOfGathering=inFile.nextLine(); costOfMeal=inFile.nextDouble(); mealSource=inFile.nextLine(); numberInvited=inFile.nextInt(); traditionalDessert=inFile.nextLine(); traditionalDrink=inFile.nextLine(); costPerDessert=inFile.nextDouble(); costPerDrink=inFile.nextDouble(); holidayGame=inFile.nextLine(); holidayStorybook=inFile.nextLine(); holidayMovie=inFile.nextLine(); costOfMovie=inFile.nextDouble(); aChild= new ChildrenTradition(holidayName,holidaySeason,timeOfDayCelebration,mainDishName,numberOfSideDishes,locationOfGathering,costOfMeal,mealSource,numberInvited,traditionalDessert, traditionalDrink,costPerDessert,costPerDrink,holidayGame, holidayStorybook,holidayMovie,costOfMovie); myFamilyTraditions.add(aChild); } } inFile.close(); return myFamilyTraditions; } public static void celebrateHolidays(ArrayList myFamilyTraditions) { for (int i = 0; i < myFamilyTraditions.size(); i++) { System.out.println(myFamilyTraditions.get(i).celebrate() +myFamilyTraditions.get(i).tabulateCosts()); } }

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Database And Knowledge Base Systems

Authors: S Krishna

1st Edition

9810206208, 978-9810206208

More Books

Students also viewed these Databases questions

Question

7 How do I can statements help learners understand what they own?

Answered: 1 week ago

Question

Guidelines for Informative Speeches?

Answered: 1 week ago