st guest1 = new Guest (" ", " ") objects in the UML diagram.  Any Advice? //-------------------First class: public class Guest { // Attributes below private String firstName; private String lastName; //constructor below public Guest(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I can make the application but seem to always have issues with the Class UML Diagram.  Below is the program I made and I attached the UML diagram.  I was not completely sure about the

Guest guest1 = new Guest (" ", " ")

objects in the UML diagram.  Any Advice?

//-------------------First class:

public class Guest {

// Attributes below
private String firstName;
private String lastName;
//constructor below
public Guest(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}

// Overloaded constructor below
public Guest() {
this("No First Name Given", "No Last Name Given");
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

@Override
public String toString() {
return firstName + " " + lastName;
}
}

//------Second class

import java.util.ArrayList;

public class GuestList {

public static void main(String[]args) {

ArrayList <Guest> nameList = new ArrayList <Guest>();
//Guest objects with names
Guest guest1 = new Guest("John", "Doe");
Guest guest2 = new Guest("Mary", "Smith");
Guest guest3 = new Guest("Jean", "Peterson");
Guest guest4 = new Guest("Sean", "Bott");
Guest guest5 = new Guest("Anna", "Hall");
//adds Guest Objects to the nameList array
nameList.add(guest1);
nameList.add(guest2);
nameList.add(guest3);
nameList.add(guest4);
nameList.add(guest5);

// Call the displayGuests().
System.out.println("Here is the list of guests.");
displayGuests(nameList);

System.out.println(); // for readability purposes

// Update the list.

// Add 2 more guests.
System.out.println("Adding Adriana Lima to the guest list.");
nameList.add(new Guest("Adriana","Lima"));

System.out.println(); // for readability purposes

System.out.println("Adding Robert Shabazz to the guest list.");
nameList.add(new Guest("Robert","Shabazz"));

System.out.println(); // for readability purposes

// Delete the guest who has registered first.
System.out.println("Deleting the first guest from the guest list...");
nameList.remove(0); // John Doe will be removed

System.out.println(); // for readability purposes

// Change the first name of guest 'Mary Smith' to 'Jane'.
System.out.println("Changing the first name of guest Mary Smith to Jane.");
for (Guest g : nameList) {
if (g.getFirstName().equalsIgnoreCase("Mary") &&
g.getLastName().equalsIgnoreCase("Smith")) {
g.setFirstName("Jane");
}
}

System.out.println(); // for readability purposes

// Call the displayGuests().
System.out.println("Here is the modified list of guests.");
displayGuests(nameList);

} // end main()

public static void displayGuests(ArrayList<Guest> guestList) {
for (Guest guest : guestList) {
System.out.println(guest.toString());
}
} // end displayGuests()
}

 

 

Dependency relationship
because GuestList invokes
Guest methods.
Class name
Guest
GuestList
-firstName:String
-lastName:String
+Guest:(String firstName, lastName)
+Guest()
+getFirstName()
+setFirstName(firstName:String):void
+getLastName()
+setLastName(lasttName:String):void
+toString()
nameList():ArrayList<Guest>
nameList.add()
displayGuests(:nameList
nameList.remove()
+displayGuests():ArrayList<Guest>
Methods
The paramiters and
return type
Transcribed Image Text:Dependency relationship because GuestList invokes Guest methods. Class name Guest GuestList -firstName:String -lastName:String +Guest:(String firstName, lastName) +Guest() +getFirstName() +setFirstName(firstName:String):void +getLastName() +setLastName(lasttName:String):void +toString() nameList():ArrayList<Guest> nameList.add() displayGuests(:nameList nameList.remove() +displayGuests():ArrayList<Guest> Methods The paramiters and return type
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education