Building multitiers program

A constructor is a special method that used to initialize the properties of the object A constructor is invoked when the object gets instantiated Note to write a constructor: The name of the constructor and the name of the class are the same A constructor does not return value, not even void A class can have multiple constructors (overloaded constructors) | Building multitiers program Week 9 Contents Review OOP Three-tier application Implementing 3-tier Slide Create class Add new class: menu Project->Add Class Create properties for a class Create methods for a class Create events for class Slide Creating properties for a class Declare all variables in a class as private (encapsulation) private properties must be assigned values and can be get values through get/set public dataType myProperty { get { return propertyName; } set { propertyName = value; } } Slide When objects are created from a class, Creating methods: Write constructors A constructor is a special method that used to initialize the properties of the object A constructor is invoked when the object gets instantiated Note to write a constructor: The name of the constructor and the name of the class are the same A constructor does not return value, not even void A class can have multiple constructors (overloaded constructors) public ClassName (parameterList) { } Instantiating an object To instantiate an object, using the new keyword Example: Lop l = new Lop(); Lop c; c = new Lop(“NCTH2K”, “Cao dang nghe 2K”); Slide ClassName object = new ClassName ( ); ClassName object; object = new ClassName ( ); Using properties, methods of a class Call methods or properties of a class Using dot operator Get/set methods: get: variable = set: = variable Example: SinhVien sv = new SinhVien(); = “Nguyen Van An”; = 5; = 10; = ().ToString(); ( + “ có ĐTB = ” + ()); Slide Contents Review OOP Three-tier application Implementing 3-tier Slide 2. Three-tier application What is a 3-tier architecture? What is the need for dividing the code in 3-tiers? Designing 3-tier Slide Physical & Logic model What is Business tier? Business object & original object Sending message between tier What is a 3-tier architecture? Three-tier . | Building multitiers program Week 9 Contents Review OOP Three-tier application Implementing 3-tier Slide Create class Add new class: menu Project->Add Class Create properties for a class Create methods for a class Create events for class Slide Creating properties for a class Declare all variables in a class as private (encapsulation) private properties must be assigned values and can be get values through get/set public dataType myProperty { get { return propertyName; } set { propertyName = value; } } Slide When objects are created from a class, Creating methods: Write constructors A constructor is a special method that used to initialize the properties of the object A constructor is invoked when the object gets instantiated Note to write a constructor: The name of the constructor and the name of the class are the same A constructor does not return value, not even void A class can have multiple constructors (overloaded constructors) public ClassName (parameterList) { } .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.