Help reading UML documents?

I've just started in a Data Structures class, and it's been two years since I've done ANYTHING c++ related. I used to be very good at it, aced my classes in c++ and java easily. But since it's been so long I can't remember a thing.
I have a uml given to me, but I was never shown how to read them, for instance the centermost box says-

-accountNum: integer
-balance: float
then below a line
+getBalance() {query}
+withdraw()
+deposit

There are no clear cut instructions. I'm just supposed to look at these boxes, which apparently are related to some Bank program, and design a c++ program.
Can anyone assist please?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
struct Account
{
    typedef int AccountNum_t;
    typedef long double Balance_t;

    Account(AccountNum_t num) : accnum(num)
    {
    }
    ~Account()
    {
    }

    Balance_t Balance() const
    {
        return balance;
    }
    void Withdraw(Balance_t amt)
    {
        balance -= amt;
    }
    void Deposit(Balance_t amt)
    {
        balance += amt;
    }
private:
    AccountNum_t const accnum;
    Balance_t balance;
};
I bolded the parts related to the chart, you should be able to connect the dots and get the idea.
Last edited on
So it's kind of like a rubric then?
I see. Thank you for that.
Quick question though, what do some of the lines mean.
E.I. * and a 1 on the line connecting Account and Customer.
Or Checking and Savings having an arrow pointing to Account.
Or Bank having a clear diamond on the line connected to account.
This all seems like an overcomplicated way to explain what someone wants in a program.
I googled "C++ UML" and got this as the first result:
http://www.objectmentor.com/resources/articles/umlClassDiagrams.pdf
The pictures seem to be matching exactly what you're describing ;)
That link was helpful, but doesn't seem to explain {query} or the number 1 on the lines.
The numbers on the lines in a UML diagram show the types of relationships between the objects in the diagram. You can have 1-1 relationships, 1--* (one-to-many) and *--* many-to-many).

You probably have a customer object in your UML, so it should be showing a 1 to many relationship between a customer and an account. i.e. A customer can have one or more accounts.
Ahh i see. Thank you. And last thing, what does {query} mean?
It only gets data, it doesn't change any data.
Thank you everyone.
Topic archived. No new replies allowed.