Need help interpreting UML for C# "College Student Here"
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开发者_StackOverflow Last Name
-ISBN Number
------------------
+checkOut
+CheckIn
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.
They wish you to create a class with 4 properties (which are private -
) and two methods (which are public +
).
Also helpful to look at the syntax first: http://en.wikipedia.org/wiki/Class_diagram.
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!
精彩评论