Expert Solution & Answer
Book Icon
Chapter 5, Problem 8E

Explanation of Solution

a.

Method heading for each method:

  • • Method heading for access method of each attribute:
    • しろまる Access method for person first name is "public String getPersonFirstName()".
    • しろまる Access method for person last name is "public String getPersonLastName()".
    • しろまる Access method for person email address name is "public String getPersonEmailAddress()"...

Explanation of Solution

b.

Preconditions and postconditions of each method:

  • • Precondition and postcondition of access method for each attribute.
    • しろまる For method "getPersonFirstName()":
      • しかく Precondition: None
      • しかく Postcondition: Returns the first name of given person.
    • しろまる For method "getPersonLastName()":
      • しかく Precondition: None
      • しかく Postcondition: Returns the last name of given person.
    • しろまる For method "getPersonEmailAddress()":
      • しかく Precondition: None
      • しかく Postcondition: Returns the email address of given person.
    • しろまる For method "getPersonTelephoneNumber()":
      • しかく Precondition: None
      • しかく Postcondition: Returns the telephone number of given person.
  • • Precondition and postcondition of "changeEmailAddress(String nEmail)" method...

Explanation of Solution

c.

Test class for some Java statement:

//Create object "p1" for "PersonAddress" class

PersonAddress p1 = new PersonAddress();

//Create object "p2" for "PersonAddress" class

PersonAddress p2 = new PersonAddress();

//Create object "p3" for "PersonAddress" class

PersonAddress p3 = new PersonAddress();

//Set values for "p1" by calling method "setPersonAddress"

p1.setPersonAddress("John", "Merry", "john123@aaa.com", "123-4567");

//Set values for "p2" by calling method "setPersonAddress"

p2.setPersonAddress("John", "Merry", "jr@ccc.com", "123-7654");

//Set values for "p3" by calling method "setPersonAddress"

p3.setPersonAddress("Jansi", "Rose", "htr@aaa.com", "333-4444");

//Display the statement

System.out.println("Values of attributes for person 1.");

//Display person "p1" first name by calling method "getPersonFirstName"

System.out.println("First Name: " + p1.getPersonFirstName());

//Display person "p1" last name by calling method "getPersonLastName"

System.out.println("Last Name: " + p1.getPersonLastName());

//Display person "p1" email address by calling method "getPersonEmailAddress"

System.out.println("Email Address: " + p1.getPersonEmailAddress());

//Display person "p1" telephone number by calling method "getPersonTelephoneNumber"

System.out.println("Telephone Number: " + p1.getPersonTelephoneNumber());

System.out.println();

//Display the given statement

System...

Explanation of Solution

d.

Implementation of class:

PersonAddress.java:

//Import package

import java.util.Scanner;

//Define class "PersonAddress"

public class PersonAddress

{

//Declare required variables in "private" access specifier

private String first_Name;

private String last_Name;

private String email_addr;

private String telephone_number;

//Set value for "PersonAddress" class

public void setPersonAddress(String f, String l, String e, String p)

{

//Assign value to given instance variables

first_Name = f;

last_Name = l;

email_addr = e;

telephone_number = p;

}

//Access method for person first name

public String getPersonFirstName()

{

//Returns person first name

return first_Name;

}

//Access method for person last name

public String getPersonLastName()

{

//Returns person last name

return last_Name;

}

//Access method for person email address

public String getPersonEmailAddress()

{

//Returns person email address

return email_addr;

}

//Access method for person telephone number

public String getPersonTelephoneNumber()

{

//Returns person telephone number

return telephone_number;

}

//Method for change person Email Address

public void changeEmailAddress(String nEmail)

{

//Assign "email_addr" to "nEmail"

email_addr = nEmail;

}

//Method for change person PhoneNumber

public void changePhoneNumber(String nPhone)

{

//Assign "telephone_number" to "nPhone"

telephone_number = nPhone;

}

//Method for check two persons are equal

public boolean equalMethod(PersonAddress otherPerson)

{

//Returns true if persons are equal

return last_Name.equals(otherPerson.last_Name) && first_Name.equals(otherPerson.first_Name);

}

//Define main function

public static void main(String[] args)

{

//Create object "p1" for "PersonAddress" class

PersonAddress p1 = new PersonAddress();

//Create object "p2" for "PersonAddress" class

PersonAddress p2 = new PersonAddress();

//Create object "p3" for "PersonAddress" class

PersonAddress p3 = new PersonAddress();

//Set values for "p1" by calling method "setPersonAddress"

p1.setPersonAddress("John", "Merry", "john123@aaa.com", "123-4567");

//Set values for "p2" by calling method "setPersonAddress"

p2.setPersonAddress("John", "Merry", "jr@ccc.com", "123-7654");

//Set values for "p3" by calling method "setPersonAddress"

p3.setPersonAddress("Jansi", "Rose", "htr@aaa.com", "333-4444");

//Display the statement

System.out.println("Values of attributes for person 1.");

//Display person "p1" first name by calling method "getPersonFirstName"

System.out.println("First Name: " + p1.getPersonFirstName());

//Display person "p1" last name by calling method "getPersonLastName"

System.out.println("Last Name: " + p1.getPersonLastName());

//Display person "p1" email addressby calling method "getPersonEmailAddress"

System...

Blurred answer
Students have asked these similar questions
Draw out an example of 3 systems using Lamport’s logical clock and explain the steps in words.
"Systems have become very powerful and sophisticated, providing quality information fordecisions that enable the firm to coordinate both internally and externally."With reference to the above statement compare the operations of any three data gatheringsystems today’s organisations use to aid decision making.
labmas Course Home XDocument courses/13810469/menu/a2c41aca-b4d9-4809-ac2e-eef29897ce04 There are three ionizable groups (weak acids and/or bases) in glutamic acid. Label them on the structure below Drag the appropriate labels to their respective targets. OOH [] CH3N CH CH2 CH2 IC HO Reset Help

Chapter 5 Solutions

Java: An Introduction to Problem Solving and Programming (8th Edition)

Chapter 5.1, Problem 11STQ Chapter 5.1, Problem 12STQ Chapter 5.2, Problem 13STQ Chapter 5.2, Problem 14STQ Chapter 5.2, Problem 15STQ Chapter 5.2, Problem 16STQ Chapter 5.2, Problem 17STQ Chapter 5.2, Problem 18STQ Chapter 5.2, Problem 19STQ Chapter 5.2, Problem 20STQ Chapter 5.2, Problem 21STQ Chapter 5.2, Problem 22STQ Chapter 5.2, Problem 23STQ Chapter 5.3, Problem 24STQ Chapter 5.3, Problem 25STQ Chapter 5.3, Problem 26STQ Chapter 5.3, Problem 27STQ Chapter 5.3, Problem 28STQ Chapter 5.3, Problem 29STQ Chapter 5.3, Problem 30STQ Chapter 5.3, Problem 31STQ Chapter 5.3, Problem 32STQ Chapter 5.4, Problem 33STQ Chapter 5, Problem 1E Chapter 5, Problem 2E Chapter 5, Problem 3E Chapter 5, Problem 4E Chapter 5, Problem 5E Chapter 5, Problem 6E Chapter 5, Problem 7E Chapter 5, Problem 8E Chapter 5, Problem 9E Chapter 5, Problem 10E Chapter 5, Problem 1P Chapter 5, Problem 2P Chapter 5, Problem 3P Chapter 5, Problem 4P Chapter 5, Problem 5P Chapter 5, Problem 1PP Chapter 5, Problem 2PP Chapter 5, Problem 3PP Chapter 5, Problem 4PP Chapter 5, Problem 5PP Chapter 5, Problem 6PP Chapter 5, Problem 7PP Chapter 5, Problem 8PP Chapter 5, Problem 9PP Chapter 5, Problem 10PP Chapter 5, Problem 11PP Chapter 5, Problem 12PP
Knowledge Booster
Background pattern image
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
    Text book image
    Programming Logic & Design Comprehensive
    Computer Science
    ISBN:9781337669405
    Author:FARRELL
    Publisher:Cengage
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781305480537
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    C++ Programming: From Problem Analysis to Program...
    Computer Science
    ISBN:9781337102087
    Author:D. S. Malik
    Publisher:Cengage Learning
    Text book image
    Programming with Microsoft Visual Basic 2017
    Computer Science
    ISBN:9781337102124
    Author:Diane Zak
    Publisher:Cengage Learning