Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

=+ Applying interpretability techniques to identify the

Answered: 1 week ago