Consider the two simple Java classes below:
First Example
class Computer {
Computer() {
System.out.println("Constructor of Computer class.");
}
void On() {
System.out.println("PC turning on...");
}
void working() {
System.out.println("PC working...");
}
void Off() {
System.out.println("PC shuting down...");
}
public static void main(String[] args) {
Computer my = new Computer();
Laptop your = new Laptop();
my.On();
my.working();
your.On();
your.working();
my.Off();
your.Off();
}
}
Second Example
class Laptop {
Laptop() {
System.out.println("Constructor of Laptop class.");
}
void On() {
System.out.println("Laptop turning on...");
}
void working() {
System.out.println("Laptop working...");
}
void Off() {
System.out.println("Laptop shuting down...");
}
}
After the program run, how do I trace (1) which object call which method (2) and how many times?
Just a little precision, I might have 100 classes and 1000s of objects each of them calling 100s of methods. I want to be able to trace (after I run the program), which object called which method and how many times.
Thanks for any suggestion.