TAILIEUCHUNG - Programming in Objective-C 2.0 edition phần 4

Để hoàn thành việc chạy trường hợp thử nghiệm, bạn cũng nên cố gắng một năm đó là chia hết cho 4 và không theo là trái như một bài tập cho bạn . Chúng tôi đã đề cập rằng Mục tiêu-C cung cấp cho các lập trình viên một số tiền to lớn của sự linh hoạt trong biểu thức hình thành. | 168 Chapter 8 Inheritance Using the @class directive is more efficient because the compiler doesn t need to process the entire file even though it is quite small it just needs to know that XYPoint is the name of a class. If you need to reference one of the XYPoint classes methods the @class directive does not suffice because the compiler would need more information it would need to know how many arguments the method takes what their types are and what the method s return type is. Let s fill in the blanks for your new XYPoint class and Rectangle methods so you can test everything in a program. First Program shows the implementation file for your XYPoint class. First Program shows the new methods for the Rectangle class. Program Added Methods import - void setOrigin XYPoint pt origin pt - XYPoint origin return origin @end Following are the complete XYPoint and Rectangle class definitions followed by a test program to try them out. Program Interface File import Foundation interface XYPoint NSObject int x int y @property int x y - void setX int xVal andY int yVal @end Extension Through Inheritance Adding New Methods 169 Program Implementation File import implementation XYPoint synthesize x y - void setX int xVal andY int yVal x xVal y yVal @end Program Interface File import Foundation @class XYPoint interface Rectangle NSObject int width int height XYPoint origin property int width height - XYPoint origin - void setOrigin XYPoint pt - void setWidth int w andHeight int h - int area - int perimeter @end Program Implementation File import implementation Rectangle synthesize width height - void setWidth int w andHeight int h 170 Chapter 8 Inheritance width w height h void setorigin Point pt origin pt int area return width height int perimeter return width height 2 Point origin return origin @end Program Test Program .

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.