TAILIEUCHUNG - CRC.Press A Guide to MATLAB Object Oriented Programming May.2007 Episode 2 Part 1

Tham khảo tài liệu ' a guide to matlab object oriented programming episode 2 part 1', kỹ thuật - công nghệ, cơ khí - chế tạo máy phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 174 A Guide to MATLAB Object-Oriented Programming INDEPENDENT INVESTIGATIONS 1. Try your hand at adding a couple of other shape-specific classes. You might try adding a square or a triangle. For some real fun try creating the corner points using rand. Think about how you might add a shape with no corners like a circle. 2. Define a child of cStar called cGreenStar and construct it so that when drawn the star is green rather than blue. 13 Object Arrays with Inheritance With the introduction of cStar and cDiamond the same class no longer represents both stars and diamonds. Even though both are derived from cShape and even though neither adds new features cStar and cDiamond objects are different. These differences cast a big shadow on design because they force difficult choices between inheritance and vectorization. Here we discuss the differences and add some implementation details to our classes. WHEN IS A CSHAPE NOT A CSHAPE One of the nice things about inheritance virtual functions polymorphism and arrays of objects is the promise that MATLAB will always find and execute the right function based on the object s type. Following this to its conclusion you might get the idea that a cShape array should be able to hold objects in any combination of cShape cStar and cDiamond. In reality the vectorized implementation inside cShape s group of eight cannot deal with a mixture of types. Vectorized operations rely on every object having exactly the same private structure and exactly the same type. Therefore even though cStar objects can masquerade as cShape objects with respect to building object arrays there is definitely a difference. Unfortunately MATLAB currently permits some questionable syntax. For example using the code from Chapter 12 the commands in Code Listing 74 execute without causing an immediate error. The command in line 1 concatenates objects of different types. Line 2 is a variation on line 1. To make matters worse the class reported for my_shapes

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.