반응형

2020/04/09 3

[016] 의존(Dependency) 관계 실습

소스 코드 Item.cs namespace 의존_관계 { public class Item { string text; public string Text { get { return text; } set { text = value; BindingSystem.ChangedValue(this); } } public Item(string text) { this.text = text; } public override string ToString() { return text; } } } ItemControl.cs using System; namespace 의존_관계 { public class ItemControl { bool isshow; public Item Item { get; set; } public string..

[015] C# 연관 관계(Association) 실습 – 의사, 약사

소스 코드 Druggist.cs using System; namespace 연관_관계_실습 { class Druggist { public void WorkWith(Doctor doctor) { Console.WriteLine("약사 - WorkWith"); doctor.WorkWith(this); Hasty(); } public void Hasty() { Console.WriteLine("조재하다."); } } } Doctor.cs using System; namespace 연관_관계_실습 { class Doctor { public void WorkWith(Druggist druggist) { Console.WriteLine("의사 - WorkWith"); druggist.WorkWith(this); T..

[014] C# 직접 연관 관계(Direct Association) 실습 – 계산기, 사각형

소스 코드 Rectangle.cs namespace 직접_연관_관계_실습 { class Rectangle { public int Height { get; private set; } public int Width { get; private set; } public Rectangle(int height, int width) { Height = height; Width = width; } } } Calculator.cs namespace 직접_연관_관계_실습 { class Calculator { public int CalculateArea(Rectangle rectnagle) { int width = rectnagle.Width; int height = rectnagle.Height; return width ..

반응형