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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started