Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Counter.java

Name: Anonymous 2014-09-04 11:02

why the fuck do retards have to invent a goddamned class just to use a goddamned integer? have people no shame?

Counter.java

/**
* A simple counter class that can be initialized to
* a specific value, incremented, and cleared.
* @author Owen Astrachan
*/

public class Counter
{
int myCount;

/**
* Construct a counter whose value is zero.
*/
public Counter()
{
myCount = 0;
}

/**
* Construct a counter with given initial value.
* @param init is the initial value of the counter
*/

public Counter(int init)
{
myCount = init;
}

/**
* Returns the value of the counter.
* @return the value of the counter
*/
public int getValue()
{
return myCount;
}

/**
* Zeros the counter so getValue() == 0.
*/
public void clear()
{
myCount = 0;
}

/**
* Increase the value of the counter by one.
*/
public void increment()
{
myCount++;
}

/**
* Return a string representing the value of this counter.
* @return a string representation of the value
*/

public String toString()
{
return ""+myCount;
}
}

Name: Cudder !MhMRSATORI 2014-09-06 11:43

>>18
Yes, no.

>>19
There's a difference between using abstraction because you understand what it abstracts and how it can be useful and what the limitations are, and using it because someone told you to.

It's like giving a kid a calculator and telling her ("maths is hard!") that it'll solve all her homework maths problems. Sure it works for the simple stuff, and she'll feel like she won't ever have to learn arithmetic, but what if the result overflows? Even worse, what if it produces subtly wrong answers? Someone who doesn't know how arithmetic works can be easily made to believe that 2+2=5, 1+4=7, or whatever the calculator says, in the same way that someone who doesn't understand software can be persuaded to believe anything about how computers work. A calculator is a (very leaky) abstraction, just like software.

Thankfully there are sane people teaching maths (http://www.bbc.com/news/education-20259382 ), but unfortunately this hasn't been true for computer science.

>>13
You might do better to copy the useful posts only, and leave out the /pol/ idiots.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List