*Revise this program to work efficiently and include public and private methods
ID: 3535791 • Letter: #
Question
*Revise this program to work efficiently and include public and private methods where necessary.
// Exercise 29.3: WebComponentsBean.java
package WebComponents.src.java.webcomponents;
import javax.faces.bean.ManagedBean;
@ManagedBean( name="webComponentsBean")
public class WebComponentsBean
{
private String firstName;
private String lastName;
private String email;
private String phone;
private String book;
private String operatingSystem;
// get the firstName
public String getFirstName()
{
return firstName;
} // end method getFirstName
// set the firstName
public void setFirstName( String firstName )
{
this.firstName = firstName;
} // end method setFirstName
// get the lastName
public String getLastName()
{
return lastName;
} // end method getFirstName
// set the lastName
public void setLastName( String lastName )
{
this.lastName = lastName;
} // end method setLastName
// get the email address
public String getEmail()
{
return email;
} // end method getEmail
// set the email address
public void setEmail( String email )
{
this.email = email;
} // end method setEmail
// get the phone number
public String getPhone()
{
return phone;
} // end method getPhone
// set the phone number
public void setPhone( String phone )
{
this.phone = phone;
} // end method setPhone
// get the selected book
public String getBook()
{
return book;
} // end method getBook
// set the selected book
public void setBook( String book )
{
this.book = book;
} // end method setBook
// get the selected operating system
public String getOperatingSystem()
{
return operatingSystem;
} // end method getOperatingSystem
// set the selected operating system
public void setOperatingSystem( String operatingSystem )
{
this.operatingSystem = operatingSystem;
} // end method setOperatingSystem
// returns result for rendering on the client
public String getResult()
{
if ( firstName != null && lastName != null && email != null &&
phone != null && email != book && operatingSystem != null )
return "<p +
"padding:5px">First Name: " + getFirstName() +
"<br/>Last Name: " + getLastName() +
"<br/>E-Mail: " + getEmail() +
"<br/>Phone: " + getPhone() +
"<br/>Book: " + getBook() +
"<br/>Operating System: " + getOperatingSystem() + "</p>";
else
return ""; // request has not yet been made
} // end method getResult
} // end class WebComponentsBean
Explanation / Answer
The methods .... getFirstName().........getLastName()....,.....getEmail().......getPhone()...getBook()...............getPhone()... should be private
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.