Skip to content

Instantly share code, notes, and snippets.

@wildskyf
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save wildskyf/573bf920f7d2f8176bbf to your computer and use it in GitHub Desktop.

Select an option

Save wildskyf/573bf920f7d2f8176bbf to your computer and use it in GitHub Desktop.
PL-FP
public class MenuItem {
private String name;
private String description;
private boolean vegetarian;
private double price;
public MenuItem(String name, String description,boolean vegetarian, double price)
{
this.name = name;
this.description = description;
this.vegetarian = vegetarian;
this.price = price;
}
public String getName()
{
return name;
}
public String getDescription()
{
return description;
}
public boolean isVegetarian()
{
return vegetarian;
}
public double getPrice()
{
return price;
}
public void print()
{
System.out.print(" " + name);
if (vegetarian)
{
System.out.print("(v)");
}
System.out.println(", " + price);
System.out.println(" -- " + description);
}
public static void main(String[] args)
{
MenuItem menuitem = new MenuItem("Steak","Smells nice",false,500);
System.out.println(menuitem.getName());
System.out.println(menuitem.getDescription());
System.out.println(menuitem.isVegetarian());
System.out.println(menuitem.getPrice());
menuitem.print();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment