Question: Create a public static Boolean field named debugMode and initialize debugMode with false. Ex: If the input is Meg Jan Ken, then the output is:

Create a public static Boolean field named debugMode and initialize debugMode with false.
Ex: If the input is Meg Jan Ken, then the output is:
Debug mode ON: print() called
Client is Meg.
Debug mode ON: print() called
Client is Jan.
Debug mode ON: print() called
Client is Ken.
Note: Debugging is commonly done with output messages. A static Boolean field like debugMode controls whether the debugging message is to be shown or hidden. public class Client {
/* Your code goes here */
private String name;
public Client(String newName){
if (debugMode){
System.out.println("Debug mode ON: Client's constructor called");
}
name = newName;
}
public void print(){
if (debugMode){
System.out.println("Debug mode ON: print() called");
}
System.out.println("Client is "+ name +".");
}
} NewClients.java: import java.util.Scanner;
public class NewClients {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
Client client1= new Client(scnr.next());
Client client2= new Client(scnr.next());
Client client3= new Client(scnr.next());
Client.debugMode = true;
client1.print();
client2.print();
client3.print();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!