SRL Archive - Java Help and Tutorials

Woot! my first project!


mikevskater

2008-07-05 11:10:10

package Project;

public class Increasetwo
{

public static int Increase(int value, int Amount)
{
return value + Amount;

}

public static void main(String[] args)
{
int i = 0;
System.out.println(i);
while(i < 100)
{
i = Increase(i, 5);
System.out.println(i);
}
System.out.println("All Done");
}

}
What do you think?

pointer

2008-07-05 15:09:53

Have you tested if it works? I think you might get a error which says that it doesn't know what "value" is, so you have to declare it

mikevskater

2008-07-05 17:53:39

Yeah it works
I did declare value…
"public static int Increase(int value, int Amount)"

pointer

2008-07-05 19:01:09

ok, it's fun then ;)

ShawnjohnSJ

2008-08-06 17:03:39

Doesn't work. You fail.
:-] jk Good job

Pwnd

2008-08-16 00:17:32

You could probably use OOP more. I have a few things you could do with this:


public class IncreaseTwo
{
private int count = 0;

public int increase(int value, int amount)
{
return value + amount;

}

public int getCount() {
return count;
}

public void setCount(int count) {
this.count = count;
}

public static void main(String[] args)
{
IncreaseTwo it1 = new IncreaseTwo();
System.out.println(it1.getCount());
while(it1.getCount() < 100)
{
it1.setCount(it1.increase(it1.getCount(), 5);
System.out.println(it1.getCount());
}
System.out.println("All Done");
}

}

This just allows you to have several more instances going on at once (If you ever needed it).

mpd

2008-08-23 10:00:06

Yes, and always respect the coding conventions

for java:
classes start with a capital
functions & variables don't