Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. Requirements:
  2.  
  3. The purpose of this exercise is extend your understanding of OOP. In the Pizza exercise, we instantiated an object of a class, and called its methods. In this exercise, we will perform some modifications to that class. The API of the class (the method names and return types) should all remain the same. The only API change we will make is the constructor parameters (as specified below). Although the API will largely remain the same, you may need to change method implementations to achieve the desired result.
  4.  
  5. Your task is to modify the Pizza class from the previous exercise. You are provided with an identical copy of the Pizza class. Right click this class in the Package Explorer and click Refactor -> Rename.... Rename the class to PizzaModified. Eclipse will automatically update all references to this class:
  6.  
  7. The name of the file.
  8. The class name (within the code).
  9. The constructor name.
  10. As you can see, this is a very handy tool!
  11.  
  12. Next, change the constructor from:
  13. PizzaModified(int price, String type)
  14.  
  15.  
  16. to:
  17. PizzaModified(PizzaType type)
  18.  
  19.  
  20. This will cause a number of warnings and compiler errors. You will need to update the rest of the class based on this new parameter, while still keeping all the method names and return types unchanged. Take note of the parameter's type PizzaType, which refers to the provided enum PizzaType.java. This allows you to use the methods in PizzaType to enable you to write cleaner code.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement