~cpp void printOwing(double amount){ printBanner(); // print details System.out.println( "name:" + _name); System.out.println( "amount" + amount); }
~cpp void printOwing(double amount){ printBanner(); // print details printDetails( amount ); } void printDetails (double amount){ System.out.println( "name:" + _name); System.out.println( "amount" + amount); }
~cpp int getRating(){ return (moreThanFiveLateDeliveries())?2:1; } boolean moreThanFiveLateDeliveries(){ return _numberOfLateDeliveries > 5; }
~cpp int getRating(){ return (_numberOfLateDeliveries>5)?2:1; }
~cpp double basePrice = anOrder.basePrice(); return (basePrice > 1000)
~cpp return (anOrder.BasePrice() > 1000)
~cpp if ( (platform.toUpperCase().indexOf("MAC") > -1) && (browser.toUpperCase().indexOf("IE") > -1) && wasInittialized() && resize > 0) { // do something }
~cpp final boolean isMacOs = platform.toUpperCase().indexOf("MAX") > -1; final boolean isIEBrowser = browser.toUpperCase().indexOf("IE") > -1); final boolean wasResized = resize > 0; if ( isMaxOs && isIEBrowser && wasResized ) { // do something }
~cpp double temp = 2 * (_height + _width); System.out.println (temp); temp = _height * _width; System.out.println(temp);
~cpp final double perimeter = 2 * (_height + width); System.out.println(perimeter); final dougle area = _height * _width; System.out.println(area);
~cpp int descount ( int inputVal, int Quantity, int yearToDate) { if (inputVal > 50) inputVal -= 2;
~cpp int descount ( int inputVal, int Quantity, int yearToDate) { int result = inputVal; if (inputVal > 50) return -= 2;
~cpp class Order ... double price() { double primaryBasePrice; double secondaryBasePrice; double teriaryBasePrice; // long computation; ... }
~cpp String foundPerson(String[] people){ for (int i = 0; i < people.length; i++) { if (people[i].equals ("Don")){ return "Don"; } if (people[i].equals ("John")){ return "John"; } if (people[i].equals ("Kent")){ return "Kent"; } } return ""; }
~cpp String foundPerson(String[] people){ ListCandidates = Arrays.asList(new String[] {"Don", John", "Kent"}); for (int i = 0; i < people.length; i++) if (candidates.contains(people[i])) return people[i]; return ""; }