Question: Hello Can you please to add anything to make code better (you dont have to change everything, just a little change). Please, explain and show

Hello

Can you please to add anything to make code better (you dont have to change everything, just a little change). Please, explain and show what you did.

public class Bell

{

private boolean bellOn = false;

private int regNum = 0;

//Bell class has two constructor:

//default constructor

public Bell (){

bellOn = false;

regNum = 123456789;

}

public Bell (boolean bellOn, int regNum){

this.bellOn = bellOn;

this.regNum = regNum;

}

//class Bell methods

public boolean activateBell()

{

bellOn=true;

return true;

}

public void setRegNum(int newRegNum)

{

this.regNum = newRegNum;

}

public void printData()

{

System.out.println("The statement your bell in on is:"+bellOn);

System.out.println("Your registration number is: "+regNum);

}

public static void main(String[] args)

{

// create new bell opbjects

Bell bell1 = new Bell();

System.out.println("Default data: ");

bell1.printData();

// Change bell1 status

bell1.setRegNum(987654321);

bell1.activateBell();

System.out.println("New data: ");

// Print new data

bell1.printData();

}

}

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!