Пример #1
0
 /**
  * Gives the candy item formatted as the receipt requires
  *
  * @return the candy info formatted
  */
 @Override
 public String toString() {
   String output =
       weight + " lbs. @ $" + DessertShoppe.cents2dollarsAndCents(pricePerLbs) + " /lb.";
   output += "\n" + super.getName();
   output +=
       String.format(
           "%" + (DessertShoppe.RECEIPT_WIDTH - super.getName().length()) + "s",
           DessertShoppe.cents2dollarsAndCents(getCost()));
   return output;
 }
Пример #2
0
 /**
  * Creates the Sundae entry for the receipt
  *
  * @return the information to be displayed on the receipt
  */
 public String toString() {
   String amount = DessertShoppe.cents2dollarsAndCents(super.getCost());
   // format the spacing for the total amount
   int width = DessertShoppe.RECEIPT_WIDTH - super.getName().length();
   // the information that will be displayed
   return toppingName
       + " Sundae with\n"
       + super.getName()
       + String.format("%" + width + "s", amount);
 }
Пример #3
0
 /** @return the name and cost of the sundae and topping */
 public String toString() {
   // output the name of the topping, ice cream and costs
   String output = this.toppingName + " Sundae with " + "\n";
   output += this.getName();
   // format to line up the price
   int widthPreCost = DessertShoppe.RECEIPT_WIDTH - this.getName().length();
   output +=
       String.format("%" + widthPreCost + "s%n", DessertShoppe.cents2dollarsAndCents(getCost()));
   // return the whole purchase onto the reciept
   return output;
 }