Week6 fromUMLtoCode
Week6 fromUMLtoCode
Week 6
Software Engineering
Wk Lecture Practical
1 Introduction Canvas, Assessment Understand the case study.
Software lifecycle Write the user stories.
Design the database and the
2 Work as a group! Agile
software
Plan the work on the UI Review of the software requirements and
Set the version control
and the Use Case design
diagram. Review of the OOP concepts.
3 User Stories Git
4 Plan the work on the Graphical User Interface. MVC pattern. Coding
user stories Retrospective
Check if you are on track.
5 Plan the work on the Create and connect the database to the
database application.
From UML to C# code
6 Plan the current task Testing
class MenuItem {
// attributes
private string itemName;
private double itemPrice;
}
UML class to C# class
Example
UML class Menu
Equivalent C# class
class Menu{
private string title;
public void addMenuItem(MenuItem menuItem) {
......
}
}
UML class to C# class – Activity 1
Example
Write the C# classes for the following two classes
Pet Owner
Name:string
name:string 1..* 1
Address:string
age:int
phoneNo:string
eat()
play(time:int) feedPet(food:string)
cleanPet()
playWithPet(time:int)
The relationships between classes
Pet Person
1..* 1 name:string
name:string
address:string
age:int
phoneNo:string
eat()
play(time:int) feedPet(food:string)
cleanPet()
playWithPet(time:int)
Aggregation between classes
Car Wheel
manufacturer:string 0-4 brand:string
stop()
}
UML class to C# class – Activity 3
Example
Write the C# code for the relationship between the classes
Pet Owner
name:string name:string
1..* 1
age:int
feedPet(food:string)
cleanPet()
eat()
playWithPet(time:int)
play(time:int)
UML class to C# class – Activity 3
public class Pet{ public class Owner{
// attributes // attributes
private string name; private string name;
private int age; private List<Pet> petList;
}
public Owner(List<Pet>
petList){
this.petList = petList;
}
}
Pet Owner
name:string name:string
1..* 1
age:int
feedPet(food:string)
cleanPet()
eat()
playWithPet(time:int)
play(time:int)
Composition between classes
Client BankAccount
name:string 1 amount:double
checkBalance() checkAccountBalance()
public Client() {
acc = new BankAccount();
}
public double checkBalance() {
return acc.checkAccountBalance();
}
}
UML class to C# class – Activity 4
Example
Write the C# code for the relationship between the classes
Schedule Student
1..* name:string
time:string
UML class to C# class – Activity 3
public class Schedule{ public class Student{
// attributes // attributes
private string time; private string name;
} private List<Schedule>
scheduleList;
public Student() {
scheduleList = new
List<Schedule>();
}
Schedule Student
1..* name:string
time:string
Inheritance
superclass
Inheritance
subclass
Inheritance
C# code:
size
itemName
Inherited from the superclass
itemPrice MenuItem
Questions