Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. /**
  2. * @(#)Sandwich.java
  3. *
  4. * Sandwich application
  5. *
  6. * @author
  7. * @version 1.00 2018/12/13
  8. */
  9.  
  10. public class Sandwich {
  11. private String mainIng;
  12. private String bread;
  13. private double price;
  14. public void setMainIng(String ing){
  15. mainIng = ing;
  16. }
  17. public String getMainIng(){
  18. return mainIng;
  19. }
  20. public void setBread(String breadType){
  21. bread = breadType;
  22. }
  23. public String getBread(){
  24. return bread;
  25. }
  26. public void setPrice(double itemPrice){
  27. price = itemPrice;
  28. }
  29. public double getPrice(){
  30. return price;
  31. }
  32. }
  33.  
  34.  
  35.  
  36.  
  37. ============================================================================================
  38.  
  39. public class TestSandwich {
  40.  
  41. /**
  42. * Method main
  43. *
  44. *
  45. * @param args
  46. *
  47. */
  48. public static void main(String[] args) {
  49. Sandwich sandwich = new Sandwich();
  50. sandwich.setMainIng("fish");
  51. sandwich.setBread("Rye");
  52. sandwich.setPrice(4.99);
  53. System.out.println("You have ordered a " + sandwich.getMainIng() + " sandwich on " + sandwich.getBread() + " bread, and the price is " + sandwich.getPrice());
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement