/**4-2
* Use the Calculator class written in the third experiment to programmatically manage the lending of the conference room projector.
* Each newly purchased a projector or retract a projector, counter plus 1;
* Each projector is eliminated or a projector is borrowed, the counter minus 1
**/
public class Adu{public static void Main (string[] args) {Counter n = new Counter (); System.out.println ("Buy or withdraw a set:" + n.increment ()); System.out.println ("Retire or lend a single:" + N.decrement ()); System.out.println ("Re-purchase or recovery of one:" + n.increment ()); System.out.println ("re-obsolete or lending a single:" + N.decrement ());}} class Counter{private static int countervalue = 5;int increment () {return ++countervalue;} int decrement () {return--countervalue;} int reset () {countervalue = 0;return 0;}}
Those years, learn together Java 4-2