![]() |
![]() |
|
home—info—lects—labs—exams—hws
tutor/PIs—Object120 + its docs—java.lang docs—java.util docs
/** Some bakery price-calcuating functions.
* @author ???
* @see http://www.radford.edu/~itec120/2010fall-ibarland/Labs/lab04a.html
*/
class Bakery extends Object120 {
/** Return the cost for multiple bakery items, in cents.
* @param itemName The product being ordered; must be either "donut" or "fritter".
* @param count The number items being ordered.
* @return the list price for `count` `itemName`s, including any discounts, *in cents*.
*/
// (Add your code here, *after* filling in the test cases below.)
/** Test the above function. */
static void testPrices() {
System.out.println( "0 donuts:" );
System.out.println( "Actual: " + orderPrice( "donut", 0 ) );
System.out.println( "Expect: ???" );
System.out.println( "1 donut:" );
System.out.println( "Actual: " + orderPrice( "donut", 1 ) );
System.out.println( "Expect: ???" );
System.out.println( "2 donuts:" );
System.out.println( "Actual: " + orderPrice( "donut", 2 ) );
System.out.println( "Expect: ???" );
System.out.println( "10 donuts:" );
System.out.println( "Actual: " + orderPrice( "donut", 10 ) );
System.out.println( "Expect: ???" );
System.out.println( "100 donuts:" );
System.out.println( "Actual: " + orderPrice( "donut", 100 ) );
System.out.println( "Expect: 6175" ); // 6500¢ less 5% (325¢)
System.out.println( "0 fritters:" );
System.out.println( "Actual: " + orderPrice( "fritter", 0 ) );
System.out.println( "Expect: ???" );
System.out.println( "1 fritter:" );
System.out.println( "Actual: " + orderPrice( "fritter", 1 ) );
System.out.println( "Expect: ???" );
System.out.println( "2 fritters:" );
System.out.println( "Actual: " + orderPrice( "fritter", 2 ) );
System.out.println( "Expect: ???" );
System.out.println( "4 fritters:" );
System.out.println( "Actual: " + orderPrice( "fritter", 4 ) );
System.out.println( "Expect: ???" );
System.out.println( "100 fritters:" );
System.out.println( "Actual: " + orderPrice( "fritter", 100 ) );
System.out.println( "Expect: ???" );
}
}
|
"howdy" == Object120.toLowerCase("hOWdy"); // false!!
String s;
s = "how";
s == s+"" // false!!
|
Go ahead and add one more case:
home—info—lects—labs—exams—hws
tutor/PIs—Object120 + its docs—java.lang docs—java.util docs
| ©2010, Ian Barland, Radford University Last modified 2010.Sep.23 (Thu) |
Please mail any suggestions (incl. typos, broken links) to ibarland |
![]() |