Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Implementing a UML association

Question posted by: =?Utf-8?B?UGFvbG8=?= (Guest) on August 8th, 2008 05:25 AM
I have 3 classes - their associations are modelled in UML thus:

Class A: 1 --1..* Class B: 1 --1..* Class C

How would I implement this in C#?

Thanks


=?UTF-8?B?QXJuZSBWYWpow7hq?='s Avatar
=?UTF-8?B?QXJuZSBWYWpow7hq?=
Guest
n/a Posts
August 9th, 2008
12:05 AM
#2

Re: Implementing a UML association
Paolo wrote:
Quote:
I have 3 classes - their associations are modelled in UML thus:
>
Class A: 1 --1..* Class B: 1 --1..* Class C
>
How would I implement this in C#?


Let A contain a List<Band B contain a List<C>.

And make the code enforce minimum of 1 element,
if that is really important.

Arne

=?Utf-8?B?UGFvbG8=?='s Avatar
=?Utf-8?B?UGFvbG8=?=
Guest
n/a Posts
August 10th, 2008
02:45 AM
#3

Re: Implementing a UML association
Arne: thank you for the reply. I am new to C# so sorry if this next question
is a bit basic. When I create an instance of Class A I would create a
List<class Bas part of the instantiation. As I create a number of instances
of class B in my application presumably I then have to Add them to the
List<class Bin the class A object?

"Arne Vajhøj" wrote:
Quote:
Paolo wrote:
Quote:
I have 3 classes - their associations are modelled in UML thus:

Class A: 1 --1..* Class B: 1 --1..* Class C

How would I implement this in C#?

>
Let A contain a List<Band B contain a List<C>.
>
And make the code enforce minimum of 1 element,
if that is really important.
>
Arne
>


=?UTF-8?B?QXJuZSBWYWpow7hq?='s Avatar
=?UTF-8?B?QXJuZSBWYWpow7hq?=
Guest
n/a Posts
August 10th, 2008
03:05 AM
#4

Re: Implementing a UML association
Paolo wrote:
Quote:
"Arne Vajhøj" wrote:
Quote:
>Paolo wrote:
Quote:
>>I have 3 classes - their associations are modelled in UML thus:
>>>
>>Class A: 1 --1..* Class B: 1 --1..* Class C
>>>
>>How would I implement this in C#?

>Let A contain a List<Band B contain a List<C>.
>>
>And make the code enforce minimum of 1 element,
>if that is really important.

I am new to C# so sorry if this next question
is a bit basic. When I create an instance of Class A I would create a
List<class Bas part of the instantiation. As I create a number of

instances
Quote:
of class B in my application presumably I then have to Add them to the
List<class Bin the class A object?


The list should be private, so either the B's should be created and
added inside A or something outside A should create them and
call a method in A that does the add.

Arne

=?Utf-8?B?UGFvbG8=?='s Avatar
=?Utf-8?B?UGFvbG8=?=
Guest
n/a Posts
August 10th, 2008
03:55 AM
#5

Re: Implementing a UML association
Arne: thank you. I shall proceed as you recommend.

"Arne Vajhøj" wrote:
Quote:
Paolo wrote:
Quote:
"Arne Vajhøj" wrote:
Quote:
Paolo wrote:
>I have 3 classes - their associations are modelled in UML thus:
>>
>Class A: 1 --1..* Class B: 1 --1..* Class C
>>
>How would I implement this in C#?
Let A contain a List<Band B contain a List<C>.
>
And make the code enforce minimum of 1 element,
if that is really important.

I am new to C# so sorry if this next question
is a bit basic. When I create an instance of Class A I would create a
List<class Bas part of the instantiation. As I create a number of

instances
Quote:
of class B in my application presumably I then have to Add them to the
List<class Bin the class A object?

>
The list should be private, so either the B's should be created and
added inside A or something outside A should create them and
call a method in A that does the add.
>
Arne
>


 
Not the answer you were looking for? Post your question . . .
190,077 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors