Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Java UML diagram

  1. Mar 11, 2008 #1
    So I have to create a UML diagram for my program:
    Code (Text):
    import java.util.*;
    import java.text.*;

    public class NameDate {


        public static void main(String[] args) {
            // Input the first, middle, and last name
            // Display the name and the date.
            String firstNameString, middleNameString, lastNameString;
           
            //Create a Scanner object
            Scanner inputScanner = new Scanner(System.in);
           
            //Objects needed for date.
            Date todayDate = new Date();
            SimpleDateFormat formattingSimpleDateFormat=
                new SimpleDateFormat("MMMM dd yyyy");
           
            //Input the data
            System.out.print("Enter your first name  ");
            firstNameString = inputScanner.next();
           
            //middleNameString enter middle name.
            System.out.print("Enter your middle name  ");
            middleNameString = inputScanner.next();

           
            System.out.print("Enter your last name ");
            lastNameString = inputScanner.next();
           
            //Print out first, middle, and last name with date.  
            System.out.println("Hello" + " " + lastNameString + "," + " " + firstNameString + " " + middleNameString.substring(0,1) + "." + " " + "Today is" + " "
            + formattingSimpleDateFormat.format(todayDate));
        }

    }
    My professor wants me to do it like so:

    Class
    Variables
    Objects
    Methods.

    I came up with this but I'm not exactly sure I did it right.

    NameDate
    Variables
    firstNameString
    middleNameString
    lastNameString
    Objects
    todayDate
    formattingSimpleDateFormat
    Methods
    System.out.print
    System.out.println
    inputScanner
     
  2. jcsd
  3. Mar 11, 2008 #2

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    You can't really do a UML diagram of this... it's just one class, with only one method. It'd be kind of boring.

    - Warren
     
  4. Mar 11, 2008 #3
    yeah, but i only need to do a diagram for this class.

    kind of unsure how to do it.
     
  5. Mar 11, 2008 #4

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    A diagram of one class is... a box. With a name in it. That's all.

    - Warren
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook