Starting from:
$35

$29

Homework 3 Build A Burger Part 2 Solution




Description:




Often times, design patterns work together. In Homework #1, Build A Burger, you used the Decorator Design Pattern to create a java program that allowed the user to create a cheeseburger with extra toppings and print out the order and total cost. For Part #2, you are to use the Factory Design Pattern to add four different base burgers: BasicBurger, SalmonBurger, BeyondBurger and BlackbeanBurger.




Implementation Details:




From Homework #2:




You will create a maven project, including unit tests, using the template provided for this assignment. Each class and interface will be in a separate file. You will create the interface, base class, abstract decorator class and five decorator classes. The interface will be named Burger and should contain a single abstract method: public double makeBurger().




Your base class should be called BasicBurger.




The names of the five decorator classes are: GrilledOnions, FriedEgg, Bacon, Avocado and RoastedPeppers.




The basic burger will cost $6.50 and the cost of the five extra toppings a customer can pay for will be $2.00 each.










***See the InClassDecorator example on Blackboard for the decorator pattern***

CS 342 Homework #3




























New in Homework #3:




In addition to BasicBurger, you will add the following three base burgers: SalmonBurger, BeyondBurger and BlackbeanBurger; each in its own class with these names. The cost of each burger $6.50.




You will define a class called BurgerFactory that will implement the static method getBurger(). This method will take a String as a parameter and return an instance of the burger selected. The strings this method should recognize are:




“bb” for a BasicBurger, “sb” for SalmonBurger, “by” for a BeyondBurger and “blb” for a BlackbeanBurger. If the string is not recognized, the method should return a BasicBurger.




We will test your program in main by building different burgers and printing the results, for example:




Burger order =




new Avocado(new FriedEgg(new GrilledOnions(BurgerFactory.getBurger(“bb”)));




double cost = order.makeBurger();




System.out.println(“Total: $” + cost);




Will result in the following output:




Black Bean Burger $6.50




Grilled Onions $2.00



Fried egg $2.00 Total: $10.50



Test Cases:




You must include a minimum of 10 unit tests in the FactoryTest.java file provided in the Maven template project. These must run with the maven command “test”.
CS 342 Homework #3




Electronic Submission:




Put the template folder with your files in a .Zip and submit to the link on Blackboard course website.







Assignment Details:




We will run all projects with maven commands from the command line. If it does not build, it will be a zero.




Late work on a homework is NOT ACCEPTED. Anything past the deadline will result in a zero.




Unless stated otherwise, all work submitted for grading *must* be done individually. While we encourage you to talk to your peers and learn from them, this interaction must be superficial with regards to all work submitted for grading. This means you *cannot* work in teams, you cannot work side-by-side, you cannot submit someone else’s work (partial or complete) as your own. The University’s policy is available here:




https://dos.uic.edu/conductforstudents.shtml.







In particular, note that you are guilty of academic dishonesty if you extend or receive any kind of unauthorized assistance. Absolutely no transfer of program code between students is permitted (paper or electronic), and you may not solicit code from family, friends, or online forums. Other examples of academic dishonesty include emailing




your program to another student, copying-pasting code from the internet, working in a group on a homework assignment, and allowing a tutor, TA, or another individual to write an answer for you. It is also considered academic dishonesty if you click someone else’s iClicker with the intent of answering for that student, whether for a quiz, exam, or class participation. Academic dishonesty is unacceptable, and penalties range from a letter grade drop to expulsion from the university; cases are handled via the official student conduct process described at https://dos.uic.edu/conductforstudents.shtml.

More products