001package headfirst.composite.menu;
002
003public class MenuItem extends MenuComponent {
004        String name;
005        String description;
006        boolean vegetarian;
007        double price;
008
009        public MenuItem(String name,
010                        String description,
011                        boolean vegetarian,
012                        double price)
013        {
014                this.name = name;
015                this.description = description;
016                this.vegetarian = vegetarian;
017                this.price = price;
018        }
019
020        public String getName() {
021                return name;
022        }
023
024        public String getDescription() {
025                return description;
026        }
027
028        public double getPrice() {
029                return price;
030        }
031
032        public boolean isVegetarian() {
033                return vegetarian;
034        }
035
036        public void print() {
037                System.out.print("  " + getName());
038                if (isVegetarian()) {
039                        System.out.print("(v)");
040                }
041                System.out.println(", " + getPrice());
042                System.out.println("     -- " + getDescription());
043        }
044}