tailieunhanh - A Guide to MATLAB Object-Oriented Programming phần 7

Nếu dòng 61 được không thành công, các mẹ ở trên cùng của hệ thống phân cấp sẽ ném một 'MATLAB: nonExistentField' lỗi. Đường 62-63 được bỏ qua, và lỗi này là bị bắt với 64 dòng. Dòng 65 làm cho chắc chắn tìm thấy được thiết lập để sai, dòng 66 tải lỗi vào sai lầm, và dòng 67 lựa chọn một trường hợp dựa trên nhận dạng lỗi. | Constructing Simple Hierarchies with Composition 203 Code Listing 94 Modified Implementation of cShape s 1 this k . plot . 2 this k .mSize 1 this k .mPoints 1 . 3 this k .mSize 2 this k .mPoints 2 . 4 Color this k . . 5 LineWidth this k . . 6 eStyle subsref to access the graphics handle. In the case of reset MATLAB mutates the graphics handle using @cLineStyle subsasgn. Both represent composition. TEST DRIVE Using a cLineStyle object in composition involved some significant changes to cShape s implementation. A private variable for the secondary object was added and several private variables were deleted. The first few commands in the test drive need to confirm that these structural changes did not change cShape s public interface or alter its behavior. Repeating the commands from Code Listing 84 and comparing the outputs will serve this purpose. For easy reference these commands are included as the first eighteen lines in Code Listing 95. Executing lines 1-18 results in the same figures previously shown in Figures through Figure . You can also experiment with other elements included in the public interface. Code Listing 95 Chapter 15 Test Drive Command Listing for Composition 1 cd oop_guide chapter_15 2 clear classes fclose all close all force diary off 3 star cStar cStar 4 star 2 .ColorRgb 1 0 0 5 star 1 star 1 6 star draw star 7 diamond cDiamond cDiamond 8 diamond 1 .ColorRgb 0 1 0 9 diamond 2 .Size 10 diamond draw diamond 11 12 shape star diamond 13 fig_handle figure 14 for k 1 length shape 15 shape k draw shape k fig_handle 16 end 17 star draw star 18 star 1 .Title Shooting Star 19 20 shape 1 1 .LineWeight bold 21 shape 1 1 22 ans 23 Size 2x1 double 204 A Guide to MATLAB Object-Oriented Programming 24 25 26 27 ColorRgb 3x1 double Points 2x6 double LineWeight bold Title A Star is born 1 0 -1 -1 0 1 A Star is born FIGURE Combined graphic now with .

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.