Files
G4G0-1/Semester 1/Programming 1/Java/examples/debugdemo/Demo.java
2024-01-15 20:14:10 +00:00

62 lines
1.2 KiB
Java

/**
* Class Demo - this class is used in the BlueJ tutorial for demonstrating
* the BlueJ debug functionality. It contains loops and nested method calls
* that make interesting examples to set breakpoints.
*
* @author M. Kolling
* @version 13 August 1999
*/
public class Demo
{
private String name;
private int answer;
/**
* Constructor for objects of class Demo
*/
public Demo()
{
name = "Marvin";
answer = 42;
}
/**
* Loop for a while and do some meaningless computations.
*/
public int loop(int count)
{
int sum = 17;
for (int i=0; i<count; i++) {
sum = sum + i;
sum = sum - 2;
}
return sum;
}
/**
* Method for demonstrating single stepping with nested method call.
*/
public int carTest()
{
int places;
Car myCar = new Car(2, 3);
places = myCar.seats();
return places;
}
public int longloop()
{
int sum = 0;
for (int i=0; i<20000000; i++) {
sum = sum + i;
sum = sum -200;
}
return 42;
}
}