Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Write a toString function that produces a String representation of a Person object.
It is best to have a separate testing procedure for it in PersonTester. The representation it produces is illustrated by three examples:
"male person Hamlet, Prince of Denmark. Status: I see dead people!. Born 1939. Best friend of 122 people."
"female person Florence Macbeth. Status: geez. Could use some hand soap here!!!!!. Born 1990. Best friend of 1 person."
"male person Caliban. Born 1950. Best friend of 0 people."
Here are the rules.
0. You may not use an if-statement. This function is easily written with a single return statement that consists of the catenation of several parts. For readability, put each part on a separate line. You will use conditional expressions,and we give you one of them below.
1. Exactly one blank appears between words, with the exception of the status message and display name, which can have any spacing within them.
2. Get the gender with a blank after it using this conditional expression: (isMale() ? "male " : "female ") 

3. The word "person" is followed by a blank, the person's display name, and a period '.'.
4. The word "Status", the status message, and following period appear only if the status is not null. Use a conditional expression.
5. The birth year always appears.
6. The number of people calling this person their best friend and following period appear as shown in the examples. If the number of people calling this person their best friend is 1,
"person" appears; otherwise, "people" appears. Use a conditional expression.
7. Information about the male and female friends does not appear.
In testing toString, you need enough test cases to ensure that each different way of evaluating a conditional expression is tested. For example, to test whether the gender appears correctly, you need at least two test cases, for a female Person and for a male Person.
When making up a test case, construct it by hand, based on what you read above. Then, write an assertEquals statement that compares this expected value to the computed one. This is what we did.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9653485

Have any Question?


Related Questions in Computer Engineering

Question suppose we perform a sequence of n operations on a

Question : Suppose we perform a sequence of n operations on a data structure in which teh ith operation costs i 2 of i is an exact power of 2 and 1 otherwise. Use aggregrate analasys and accounting method to determine th ...

Question suppose you are buying stamps to put on a package

Question : Suppose you are buying stamps to put on a package at the post office. The postage required to send the package is N dollars. You can buy $1, $7, and $10 stamps. You want to find the minimum number of stamps re ...

We can represent a data set as a collection of object nodes

We can represent a data set as a collection of object nodes and a collection of attribute nodes, where there is a link between each object and each attribute, and where the weight of that link is the value of the object ...

Broussard skateboards sales are expected to increase by 20

Broussard Skateboard's sales are expected to increase by 20% from $8.4 million in 2015 to $10.08 million in 2016. Its assets totaled $5 million at the end of 2015. Broussard is already at full capacity, so its assets mus ...

What is vsftpd name two other server packages that may be

What is vsftpd? Name two other server packages that may be used for the same purpose

Assignment 1 multi-touch screens vs mouse-driven screensthe

Assignment 1: Multi-Touch Screens vs. Mouse-Driven Screens The following resources may be helpful when completing this assignment. • Dearden, A. (2008). User-Centered Design Considered Harmful • Norman, D. (2007-2010). A ...

1 what is the purpose of exclusive gates such as the xor

1. What is the purpose of exclusive gates such as the XOR and XNOR? 2. What function do these gates perform?

A diprotic acid solution h2a has a molarity of 065 mthe

A diprotic acid solution H 2 A has a molarity of 0.65 M.The concentrations of the species present at equilibrium are asfollows: [H + ]=0.25 M [HA - ]=0.25 [A 2- ]=4.6 x 10 -4  M The second ionization constant (K a2 ) for ...

Take the case in which all individuals are risk averse so

Take the case in which all individuals are risk averse, so that marginal costs slope down. In that case, why might it be optimal (socially efficient) for insurance take up to be less than 100%?

Question provide a real-world example or describe a

Question: Provide a real-world example or describe a hypothetical situation in which a legitimate organization used spam in an effective and nonintrusive manner to promote a product or service. Need 300-350 words APA sta ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As