B0rsuk, what's happening is this:
The constructor of Sundae is private. This means you cannot do stuff like "
Sundae _sun = new Sundae()"
.
Instead, you are supposed to use a
static method of the Sundae class which gives you a new Sundae.
static Sundae makeASundae() {
return new Sundae();
}
Since the function makeASundae is
static and
public, you can call it anywhere, including from any other class:
~~~~Inside a function of a totally different class~~~~
Sundae x = Sundae.makeASundae();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
So in fact, you
can call a makeAConnection() function of the Connection class from within the ConnectionManager. You can call it because it's public, so it can be called, and because it's static meaning you don't need an instance of Connection to run it - it's a function of the whole class, not of an object belonging to that class.
So I guess the teacher want the following to happen -
The user: _cm = new ConnectionManager ;
The user: _con = _cm.gimmeAConnection() ;
>
The _cm: *Hey, he wants a new connection!*
>
The _cm: Connection con = Connection.makeAConnection() ;
>
The _cm: *Do some mysterious adjustments to his database and the new connection*
>
The _cm: return con ; (or "
return null ;"
if failed some conditions)
>
The user: Yay, I have a connection now!
____________________________
Slay the living! Raise the dead!
Paint the sky in crimson red!