1

My teacher assigned an exercise which consists in translating (in the best possible way) a sequence diagram to Java code.

This is the sequence diagram:

enter image description here

And this is my attempt at solving this:

import java.util.ArrayList;
import java.util.List;

class Seminar {
    private int getMark() {
        return calculateMark();
    }

    private int calculateMark() {
        return 10;
    }
}

class Student {
    private List<Seminar> _seminars = new ArrayList<>();

    public List<Seminar> getSeminars() {
        return _seminars;
    }
}

class TranscriptBuilder {
    public void New(Student student) {

    }
}

But I couldn't finish TranscriptBuilder as I couldn't find anything about <<system>> and what it means. Any suggestions, please?

3 Answers 3

1

The <<system>> is a sterotype in UML :

A stereotype defines how an existing metaclass may be extended, and enables the use of platform or domain specific terminology or notation in place of, or in addition to, the ones used for the extended metaclass.

I think here it refers to the core system where you need to implement a method to print the Student information.

I suggest you @Override the toString() method in Student then implement a print() method in SharedServices as indicated in your diagram.

Sign up to request clarification or add additional context in comments.

Comments

0

You are missing the guts of the TranscriptBuilder constructor, particularly, getting the seminars and doing the loop as in the diagram.

TranscriptBuilder(Student s) {
    List<Seminar> sems = s.getSeminars();
    for (Seminar sem : sems)
        sem.getMark();
 }

2 Comments

Shouldn't that be in new() method?
Well yea. It's called a constructor though; it is a"special" method that instantiates a class.
0

Your 'system' is an Actor stereotyped 'system'.

All actors are external to your system definition. They are humans or other software systems interacting with your software.

You will not implement the printer, you will only use its API to print the result.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.