View Full Version : Woot! my first project!
mikevskater
07-05-2008, 03:10 PM
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
07-05-2008, 07:09 PM
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
07-05-2008, 09:53 PM
Yeah it works
I did declare value...
"public static int Increase(int value, int Amount)"
pointer
07-05-2008, 11:01 PM
ok, it's fun then ;)
ShawnjohnSJ
08-06-2008, 09:03 PM
Doesn't work. You fail.
:-] jk Good job
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).
Yes, and always respect the coding conventions
for java:
classes start with a capital
functions & variables don't
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.