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: Anonymous 2014-09-05 19:21

the counter example is dumb. It shows how far behind we are with program verification. They've made an integer that can't decrease in value. That's great. But does that restrict the counter to increment with the number of voters that voted for the candidate? Of course not. The programmer still has to get that right and using an integer that can't decrease doesn't make it any easier. The restricted interface also imposes difficulty. What if the algorithm doesn't go through all the voters, one at a time? What if they are processed in groups and merged? If anything, votes are implemented with database transactions and the number of votes is retrieved with a query. I bet the database library doesn't use a counter class to count the number of matching rows.

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