0% found this document useful (0 votes)
13 views1 page

Main

The document is a Java program that demonstrates the creation and manipulation of various product bundles, including items like toasters and microwaves. It showcases the use of classes such as Item, Pack, and Bundle to organize products and update prices. The program outputs the details of the created bundles and reflects changes after updating the price of one of the items.

Uploaded by

yoshiyashasganil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Main

The document is a Java program that demonstrates the creation and manipulation of various product bundles, including items like toasters and microwaves. It showcases the use of classes such as Item, Pack, and Bundle to organize products and update prices. The program outputs the details of the created bundles and reflects changes after updating the price of one of the items.

Uploaded by

yoshiyashasganil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

public class Main {

public static void main(String[] args) {


Product toaster = new Item("NeverBurn Toaster", 20.0);
Product oven = new Item("ZapIt Microwave Oven", 90.0);
// Declare toaster2 as an Item so that we can call setPrice.
Item toaster2 = new Item("AlwasyBurn Toaster", 30.0);

Product toasterPack = new Pack(4, toaster);


System.out.println("toasterPack: " + toasterPack);

Bundle homeCookingKit = new Bundle();


homeCookingKit.add(oven);
homeCookingKit.add(toaster2);
System.out.println("homeCookingKit: " + homeCookingKit);

Bundle restaurantStarterKit = new Bundle();


restaurantStarterKit.add(homeCookingKit);
restaurantStarterKit.add(new Pack(2, toaster2));
System.out.println("restaurantStarterKit: " + restaurantStarterKit);

Product homeKitPack = new Pack(5, homeCookingKit);


System.out.println("homeKitPack: " + homeKitPack);

toaster2.setPrice(35.0);
System.out.println("\nAfter updating toaster2 price to $35.00:");
System.out.println("toasterPack: " + toasterPack);
System.out.println("homeCookingKit: " + homeCookingKit);
System.out.println("restaurantStarterKit: " + restaurantStarterKit);
System.out.println("homeKitPack: " + homeKitPack);
}
}

You might also like