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.
- ○ For method “getPersonFirstName()”:
- • 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...
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Java: An Introduction To Problem Solving And Programming Plus Mylab Programming With Pearson Etext -- Access Card Package (8th Edition)
- can u solve this questionarrow_forward1. Unsigned Integers If we have an n-digit unsigned numeral dn-1d n-2...do in radix (or base) r, then the value of that numeral is n−1 r² di Σi=0 which is basically saying that instead of a 10's or 100's place we have an r's or r²'s place. For binary, decimal, and hex r equals 2, 10, and 16, respectively. Just a reminder that in order to write down a large number, we typically use the IEC or SI prefixing system: IEC: Ki = 210, Mi = 220, Gi = 230, Ti = 240, Pi = 250, Ei = 260, Zi = 270, Yi = 280; SI: K=103, M = 106, G = 109, T = 10¹², P = 1015, E = 10¹8, Z = 1021, Y = 1024. 1.1 Conversions a. (15 pts) Write the following using IEC prefixes: 213, 223, 251, 272, 226, 244 21323 Ki8 Ki 223 23 Mi 8 Mi b. (15 pts) Write the following using SI prefixes: 107, 10¹7, 10¹¹, 1022, 1026, 1015 107 10¹ M = 10 M = 1017102 P = 100 P c. (10 pts) Write the following with powers of 10: 7 K, 100 E, 21 G 7 K = 7*10³arrow_forwardanswer shoul avoid using AI and should be basic and please explainarrow_forward
- Node A is connected to node B by a 2000km fiber link having a bandwidth of 100Mbps. What is the total latency time (transmit + propagation) required to transmit a 4000 byte file using packets that include 1000 Bytes of data plus 40 Bytes of header.arrow_forwardanswer should avoid using AI and should be basic and explain pleasearrow_forwardasnwer should avoid using AIarrow_forward
- answer should avoid using AI (such as ChatGPT), do not any answer directly copied from AI would and explain codearrow_forwardWrite a c++ program that will count from 1 to 10 by 1. The default output should be: 1, 2, 3, 4, 5, 6 , 7, 8, 9, 10 There should be only a newline after the last number. Each number except the last should be followed by a comma and a space. To make your program more functional, you should parse command line arguments and change behavior based on their values. Argument Parameter Action -f, --first yes, an integer Change place you start counting -l, --last yes, an integer Change place you end counting -s, --skip optional, an integer, 1 if not specified Change the amount you add to the counter each iteration -h, —help none Print a help message including these instructions. -j, --joke none Tell a number based joke. So, if your program is called counter, counter -f 10 --last 4 --skip 2 should produce 10, 8, 6, 4 Please use the last supplied argument. If your code is called counter, counter -f 4 -f 5 -f 6 should count from 6. You should…arrow_forwardshow workarrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning