How to Structure a UML Diagram for a Basic Java Program?

  • Context: Comp Sci 
  • Thread starter Thread starter clook
  • Start date Start date
  • Tags Tags
    Diagram Java
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
clook
Messages
32
Reaction score
0
So I have to create a UML diagram for my program:
Code:
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
 
Physics news on Phys.org
chroot said:
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
yeah, but i only need to do a diagram for this class.

kind of unsure how to do it.