help creating a ULM Class Diagram, please. I have included my 3 classes of code below (UserInput, Participant, and Exchange Results).   // Participant Class class Participant  {     // Participants     private String name;     private int age;     public Participant(String name, int age)      {         this.name = name;         this.age = age;

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
100%

I need help creating a ULM Class Diagram, please. I have included my 3 classes of code below (UserInput, Participant, and Exchange Results).

 

// Participant Class
class Participant 
{

    // Participants
    private String name;
    private int age;

    public Participant(String name, int age) 
    {
        this.name = name;
        this.age = age;
    }

    // Name and Age Getters
    public String getName() 
    {
        return name;
    }

    public int getAge() 
    {
        return age;
    }
   
   // Name and Age Setters
    public void setAge(int age)  
    {
        this.age = age;
    }

    public void setName(String name) 
    {
        this.name = name;
    }
}



import java.util.Random;

// ExchangeResults Class
public class ExchangeResults 
{
    public static void main(String[] args) 
    {
        // Input Participants From The User
        UserInput userinput = new UserInput();
        Participant[] participants = userinput.inputParticipants();   

        // Shuffle The Array Of Participants
        shufflepParticipants(participants);

        // Print Gifts Exchanged
        System.out.println(" Christmas Gift Exchange Results");
        System.out.println("~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~");
        for (int i = 0; i < participants.length / 2; i++) 
        {
            Participant p1 = participants[i];
            Participant p2 = participants[participants.length - i - 1];
            System.out.printf("%s (age: %d) will echange a gift with %s (age: %d)\n",
                p1.getName(), p1.getAge(), p2.getName(), p2.getAge());
        }
    }

    // Shuffle Array Of Participants
    public static void shufflepParticipants(Participant[] participants) 
    {
        Random rand = new Random();
        Participant temp;

        // Shuffle Array
        for (int i = participants.length - 1; i > 0; i--) 
        {
            int index = rand.nextInt(i + 1);
            temp = participants[index];
            participants[index] = participants[i];
            participants[i] = temp;
        }
    }
}



// UserInput Class

import java.util.Scanner;


public class UserInput {
    Scanner input = new Scanner(System.in);

    Participant[] inputParticipants() 
    {    
        System.out.println("* * * * CHRISTMAS GIFT EXCHANGE * * * *");
        
        // Input Number Of Participants
        System.out.print("How many people are participating in the exchange? ");
        int numParticipants = Integer.parseInt(input.nextLine());
        System.out.println();

        // While Number Of Participants Is Odd,
        // Keep Inputting Number Of Participants
        while (numParticipants % 2 == 1) 
        {
            System.out.println();
            System.out.println("There must be an even number of people participating.");
            System.out.println("(Add an 'ELF' if needed.)");
            System.out.println();
            System.out.print("How many people are participating in the exchange? ");
            numParticipants = Integer.parseInt(input.nextLine());
            System.out.println();
        }

        // Initialize Array Of Participants
        Participant[] participants = new Participant[numParticipants];

        // Input All Particicpants
        for (int i = 0; i < participants.length; i++) 
        {
            System.out.printf("Participant #%d", i + 1);
            System.out.print("\n-------------------------\n");
            // Input Name And Age
            System.out.print("Name: ");
            String name = input.nextLine();
            System.out.print("Age: ");
            int age = Integer.parseInt(input.nextLine());
            participants[i] = new Participant(name, age);
            System.out.println();
        }

        // Return Array Of Participants
        return participants;
    }
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
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