1

I'm trying to convert UML to java, but, I don't know how to do this type of transformation:

enter image description here

I have Participant class:

public class Participant extends User {

    List<Competition> competitions;

    public Participant(String username, String password, String fullname) {
        super(username, password, fullname);
    }

    public Submission submitPrediction(Competition competition, float prediction) {
        return null;
    }

    public ArrayList<Submission> getSumissions() {
        return null;
    }
}

Then I have Competition:

public class Competition {

    private int id;
    private String title;
    private float target;
    private boolean isActive;

    private Organizer owner;
    private List<Participant> participants;
    private Platform platform;

    public Competition(int id, String title, float target, boolean isActive, Organizer owner, List<Participant> participants, Platform platform) {
        this.id = id;
        this.title = title;
        this.target = target;
        this.isActive = isActive;
        this.owner = owner;
        this.participants = participants;
        this.platform = platform;
    }
    .......... all methods, getters/setters, ectc............
}

And Submission:

public class Submission {
    private int id;
    private SubmissionStatus status;
    private Date submitedAt;
    private float prediction;
    private float error;

    public Submission(int id, SubmissionStatus status, Date submitedAt, float prediction, float error) {
        this.id = id;
        this.status = status;
        this.submitedAt = submitedAt;
        this.prediction = prediction;
        this.error = error;
    }
        .......... all methods, getters/setters, ectc............
}

But I don't know how to convert the dotted relation between the 3 classes.

How can I do this?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Shudy
  • 7,806
  • 19
  • 63
  • 98

1 Answers1

2

This is an association class. It is a shortcut for

enter image description here

See also this answer

Community
  • 1
  • 1
qwerty_so
  • 35,448
  • 8
  • 62
  • 86
  • SO, if I dont understand wrong, that means, that (for example) instead of have in COmpetition, something like:` private Organizer owner; private List participants; private Platform platform;` It "converts" to something like: `private Organizer owner; private List submissions; private Platform platform;` Or I don't delete `private List participants;`and I add the relation in both classes (just looking submission-competition) – Shudy Nov 16 '16 at 22:31
  • 1
    Sorry, my Java is very limited. I replaced it by a drawing. Just imagine the missing attributes/methods from your diagram. – qwerty_so Nov 16 '16 at 22:39
  • 1
    Just also added the role names. – qwerty_so Nov 16 '16 at 22:41
  • Thanks a lot! Now I understand perfect. I was messed up on how the roles will be. – Shudy Nov 16 '16 at 22:54