JavaGodPeter's blog

By JavaGodPeter, 6 months ago, In English

COMS 1004 study notes ==================

Ch3 Encapsulation ------------------ c++ import java.util.*; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); Counter A = new Counter(); A.reset(); A.click(); A.click(); int c = A.getValue(); System.out.println(c); } public static class Counter{ private int value; public void click() { value = value + 1; } public int getValue() { return value; } public void reset() { value = 0; } } }

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it