Starting from:

$30

CSE308-Problems on Structural Design Pattern Solved

Assignment # 3a

There is a method of a class named calculate Sum which takes a file as input and shows the sum of the integers written in decimal format separated by spaces in the file. Now write an adapter for this so that it can be applied on a file that contains characters separated by spaces. Using this adapter we can now add the numbers represented by the ASCII values of the characters.

You have to write methods for calculating the sum and the adapter and demonstrate using practical data.

Assignment # 3b

Consider a pizza shop selling pizza, appetizer and drinks. The following points describe the services provided to the customer.

1.       Two different types of pizzas are being sold. One is Veggi Pizza and the other is Beef Pizza. The price of these two different types of pizza will be different.

2.       There are provisions of two different types of drinks. One is Coffee and the other is Coke. The prices of these two different types of drinks are different.

3.       Onion Rings and French Fries are two different types of appetizers available with the same price of Tk 100.00.

4.       A customer can order a pizza with an appetizer.

5.       A customer can order a combo meal which consists of an appetizer, a pizza and a drink.

Construct a class indicating the following using decorator pattern:

1.       Beef Pizza with French fry

2.       Veggi Pizza with onion rings

3.       A combo meal with Veggi Pizza, French Fry and Coke

4.       A combo meal with Veggi Pizza, Onion Rings and Coffee

5.       A Beef Pizza only

In each of the cases determine the price of the options shown above as a method of the class to be created.

More products