Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick Reference have

image text in transcribedimage text in transcribedimage text in transcribed

SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick Reference have been imported where appropriate. Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied. In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods will not receive full credit. The following class represents an invitation to an event. The variable hostName represents the name of the host of the event and the variable address represents the location of the event. public class Invitation { private String host Name: private String address; public Invitation (String n, String a) { hostName = n; address = a; } (a) Write a method for the Invitation class that returns the name of the host. Write the method below. 0 / 10000 Word Limit (b) Write a method for the Invitation class that accepts a parameter and uses it to update the address for the event. Write the method below. (C) Write a method for the Invitation class that will accept the name of a person who will be invited as a string parameter and return a string consisting of the name of the person being invited along with name of the host and location of the event. For example, if the host name is "Karen, the party location is "1234 Walnut Street", and the person invited is "Cheryl, the method should return a string in the following format. See you Dear Cheryl, please attend my event at 1234 Walnut Street. then, Karen. Write the method below. Your implementation must conform to the example above. B I U iii 0 / 10000 Word Limit (d) A student has written the following one-parameter constructor to be included in the Invitation class. The method is intended to construct a new Invitation object that sets address to the value of the parameter and sets hostName to the default name "Host". The constructor does not work as intended. public Invitation (String address) { address = address; hostName = "Host"; } Write a correct implementation of the one-parameter Invitation constructor that avoids the error in the student's implementation. Write the method below

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

Step: 3

blur-text-image

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

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions