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
Click For Summary

Discussion Overview

The discussion revolves around creating a UML diagram for a basic Java program that includes a single class, NameDate. Participants explore how to represent the class, its variables, objects, and methods in UML format, while addressing the simplicity of the task.

Discussion Character

  • Exploratory, Technical explanation, Debate/contested

Main Points Raised

  • One participant shares their Java program and attempts to outline a UML diagram based on their professor's requirements, listing class name, variables, objects, and methods.
  • Another participant expresses skepticism about the value of a UML diagram for a single class with one method, suggesting it may be uninteresting.
  • There is a reiteration of the idea that a UML diagram for such a simple structure could be reduced to just a box with the class name.

Areas of Agreement / Disagreement

Participants generally agree that the UML diagram for this program is minimal due to the simplicity of the class structure, but there is uncertainty about how to effectively represent it.

Contextual Notes

The discussion does not delve into specific UML notation or conventions, and there may be assumptions about the audience's familiarity with UML diagrams.

Who May Find This Useful

Individuals interested in UML diagramming, Java programming, or those seeking guidance on representing simple class structures in UML.

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
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
 
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.
 
A diagram of one class is... a box. With a name in it. That's all.

- Warren
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 2 ·
Replies
2
Views
7K
Replies
4
Views
2K
  • · Replies 37 ·
2
Replies
37
Views
5K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K