6 Replies - 35622 Views - Last Post: 11 December 2011 - 10:27 AM Rate Topic: -----

#1 dustinm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 30-November 09

How to show an ArrayList attribute in UML class diagram?

Posted 09 December 2009 - 03:20 AM

I'm working on a project plan for my Java class, and need to do a class diagram. I have it mostly sketched out on paper, but am confused on how to represent an attribute that is an ArrayList. The program will have three classes: a Passenger class, a Train class, and a client class called TrainTrip that will demonstrate using a GUI. The Passenger class will have tow attributes, a name and a class of service (1st or 2nd class). The Train class will have only one attribute, an ArrayList which will hold a list of passengers, which will be built by reading data from a text file.

So, I have the program pretty much worked out in my head, and the UML diagram is also pretty much done, but I'm just stuck on how to show that ArrayList. Do I show ArrayList as another class, and Train associated with it?

Is This A Good Question/Topic? 0
  • +

Replies To: How to show an ArrayList attribute in UML class diagram?

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2717
  • View blog
  • Posts: 11,427
  • Joined: 20-September 08

Re: How to show an ArrayList attribute in UML class diagram?

Posted 09 December 2009 - 03:48 AM

Forget that it's an ArrayList. As far as UML concerned, it's a collection of Passenger
Was This Post Helpful? 0
  • +
  • -

#3 dustinm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 30-November 09

Re: How to show an ArrayList attribute in UML class diagram?

Posted 09 December 2009 - 03:51 AM

View Postg00se, on 9 Dec, 2009 - 02:48 AM, said:

Forget that it's an ArrayList. As far as UML concerned, it's a collection of Passenger

Ok. Now how is that shown? What would I put in the attributes box for the Train class?
Was This Post Helpful? 0
  • +
  • -

#4 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2717
  • View blog
  • Posts: 11,427
  • Joined: 20-September 08

Re: How to show an ArrayList attribute in UML class diagram?

Posted 09 December 2009 - 03:53 AM

Search on 'multiplicity indicator' at http://www.agiledata...ntation101.html
Was This Post Helpful? 1
  • +
  • -

#5 dustinm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 30-November 09

Re: How to show an ArrayList attribute in UML class diagram?

Posted 09 December 2009 - 04:41 AM

View Postg00se, on 9 Dec, 2009 - 02:53 AM, said:

Search on 'multiplicity indicator' at http://www.agiledata...ntation101.html

I get what the multiplicity indicator is, and it will read that one object of Train executes zero to many objects of Passenger. For the attribut part of the diagram for Train, would it be correct to write "-passengers : Passenger"?


I'm not sure if me not providing an example of what I have drawn so far is making it harder, so I'll try to get a quick example up later this morning.
Was This Post Helpful? 0
  • +
  • -

#6 dustinm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 30-November 09

Re: How to show an ArrayList attribute in UML class diagram?

Posted 09 December 2009 - 03:28 PM

Here's what I have for the diagram so far. If it's completely off, please let me know. I can tell that the answer to my original question is probably a lot more simple than I'm making it out to be, but I'm still a bit confused on how to represent that attribute.

Attached image(s)

  • Attached Image

This post has been edited by dustinm: 09 December 2009 - 03:29 PM

Was This Post Helpful? 0
  • +
  • -

#7 sarathsshanker  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-December 11

Re: How to show an ArrayList attribute in UML class diagram?

Posted 11 December 2011 - 10:27 AM

View Postg00se, on 09 December 2009 - 03:48 AM, said:

Forget that it's an ArrayList. As far as UML concerned, it's a collection of Passenger

this is more appropriate:
Train Class,
passengerList:ArrayList<Passenger>
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1