/* * This class models an item offered for sale at a grocery store. * A grocery item is basically the name of an item (String name) and * the price of an item in dollars (double price). Once created, * a grocery item cannot be changed. */ class GroceryItem { /* * Instance variables to store the name and price of a * grocery item. */ // These are the instance variables private String name; private double price; /* * This method is the constructor. Given the name and price, it * initializes the (newly created) object */ public GroceryItem(String name, double price) { this.name= name; this.price = price; } /* * This method returns the name of the item */ public String getName() { return name; } /* * This method returns the price of the item */ public double getPrice() { return price; } public String toString() { return name + "....." + price; } }