0

Having difficulty finding any information that relates to UML's too coding examples.

(Insert Scores Method is missing from the UML - ignore this, I am changing it now)

The Choice class uses methods from the Scores class, does this mean that there is a link between the classes? There is plenty of information regarding inheritance however, it seems.

I have created a UML: UML

Choice to Score Link

Choice Method

//Attributes Check
    public int CheckVariables(int optionR, int optionV, int TurnCount, string Username)
    {
        if (optionR >= 100 || optionV <= 0)
        {
            //return 2; //Win
            var Score = new Score();
            if(Score.InsertScores(TurnCount,Username) == true)
            {
                return 3;
            }
            else
            {
                return 2;
            }
        }
        else if (optionR <= 0 || optionV >= 100)
        {
            return 1; //Lose
        }
        else
        {
            return 0; //Not Finished
        }
    }

Score Method

public bool InsertScores(int ScoreValue,string Username)
    {
        ShowScores(); //Populate Lists with Highscores

        if(ScoreValue < Turns[9])
        {
            SqlCommand sql = new SqlCommand("UPDATE gameScores SET scoreValue = @scoreValue, username = @Username WHERE scoreid = @ScoreId;", con);
            sql.Parameters.AddWithValue("@scoreValue", ScoreValue);
            sql.Parameters.AddWithValue("@Username", Username);
            sql.Parameters.AddWithValue("@ScoreId", ScoreID[9]);
            //Insert
            sql.ExecuteNonQuery();

            return true; 
        }
        else
        {
            return false;
        }

    }
HARV mackie
  • 123
  • 1
  • 13
  • If your `Choice` class stores a instance of `Score` class as an attribute we consider it an `Association`. If it merely uses it temporarily then it's a `Dependency`. – Geert Bellekens Nov 17 '18 at 08:17
  • Please think about your design. How can you call `ShowScores` without having an association (attribute) to a `Score` object? – qwerty_so Nov 17 '18 at 08:38
  • ShowScores is inside the class, it is a method. An association attribute would make no sense. I assumed that was pretty straightforward – HARV mackie Nov 17 '18 at 18:19

1 Answers1

-1

Per the UML specification: "The objective of UML is to provide system architects, software engineers, and software developers with tools for analysis, design, and implementation of softwarebased systems as well as for modeling business and similar processes.".

This means that whether you consider "dependency" and "inheritance" equivalent depends upon your representation. Based on your images, you are defining a "meta-model" model relationship as defined by section 7.11 of the specification: https://www.omg.org/spec/UML/2.4.1/About-UML/

If you have some class A that uses methods of class B then the relationship can be modeled as 11.7.1 ElementImport.

The only real difference here is what edge descriptor you use:

enter image description here

That being said, I would urge against mixing inheritance and dependency model diagrams and to complete your current diagram, not include the import.

Community
  • 1
  • 1
Alchemy
  • 445
  • 2
  • 3
  • I don't think this answer is relevant for the question and might lead the OP in the wrong direction. – Geert Bellekens Nov 17 '18 at 08:23
  • Inheritance is not the problem. I am questioning what makes an association between classes. The Choice method checking attributes creates an instance of the Score object and accesses one of the methods (Insert Scores )that are inside the Score class, does this mean that there is a link, if so how would this be represented via a UML class diagram? – HARV mackie Nov 17 '18 at 18:25