tags:

views:

56

answers:

4

I missed class this week, due to my son being sick and I missed this portion of the lecture for the week. This is example below is what they went over in class but im having a hard time understanding what needs to be done and the book nor the teachers examples are clearly expressed so that I can understand. I guess what I need is some guidance and code this so that I can get a visual representation of what to do for my homework assignment. Thank you very much in advance.

From the following UML diagrams write the C# classes and the programs to test them.Assume you are using empty-argument constructors and public properties.

**Book** 

------------------

-Title
-Author First Name
-Author Last Name
-ISBN Number

------------------

+checkOut
+CheckIn
+3  A: 

That means the class name is Book.

It has private fields that are Title, Author First Name, Author Last Name and ISBN Number.

It also has public methods called checkOut and checkIn.

In UML + means public, and - means private.

Sergio Tapia
thank you very much
Michael Quiles
+1  A: 

They wish you to create a class with 4 properties (which are private -) and two methods (which are public +).

FallingBullets
A: 
public class Book
{
    public string Title { get; set; }
    public string AuthorFirstName { get; set; }
    public string AuthorLastName { get; set; }
    public string ISBNNumber { get; set; }

    public void checkOut()
    {
         // code to check out here
    }

    public void CheckIn()
    {
         // code to check in here
    }
}

..But, you did not provide enough information as to what the checkOut/CheckIn (inconsistent case by the way) have to do. No need for a constructor here either by the way.

(This code uses automatic properties see reference: private field members are generated for the Title,Author,ISBN and public properties for get/set)

Hope that helps!

Kieren Johnstone
I would guess that the properties should be `get` only, since the `-` does usually mean private.
FallingBullets
doesn't '-' = private, not public?
Uncle
No, because with an empty constructor it would be impossible to set the values of the fields. Would be nice to know who downvoted me.. (See again, it says public properties and empty constructor)
Kieren Johnstone
This is exactly what they went over in class sent by my professor, now what would he mean by the "and the programs to test them"? would this example be the program or am I to do something else he was very vague in his e-mail response absences are very frowned upon in my university no matter what the reason.
Michael Quiles
He's asking you to write a unit test of some sort I imagine (http://en.wikipedia.org/wiki/Unit_testing): but you'd usually be testing the behaviour of the class; and from the description this doesn't have any? (Are the check in/check out operations described?)
Kieren Johnstone
I don't think so, what I typed is verbatim what was given in class
Michael Quiles
this is part of my HW assignment would it be done the same way? Spaceship-wingSpan-rocketType-missileType-help+takeOff+land+fire+takeDamage
Michael Quiles
Of course, UML is a standard. Now you have to ask a fellow student if the teacher gave bearings on what the methods should do.
Sergio Tapia
+1  A: 

Also helpful to look at the syntax first: http://en.wikipedia.org/wiki/Class_diagram.

Mau
Thank you didn't know where to look for more information
Michael Quiles