Đang chuẩn bị liên kết để tải về tài liệu:
A Complete Guide to Programming in C++ part 55

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

A Complete Guide to Programming in C++ part 55. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | EXERCISES 519 Exercise 3 A supermarket chain has asked you to develop an automatic checkout system. All products are identifiable by means of a barcode and the product name. Groceries are either sold in packages or by weight. Packed goods have fixed prices.The price of groceries sold by weight is calculated by multiplying the weight by the current price per kilo. Develop the classes needed to represent the products first and organize them hierarchically.The Product class which contains generic information on all products barcode name etc. can be used as a base class. The Product class contains two data members of type long used for storing barcodes and the product name. Define a constructor with parameters for both data members.Add default values for the parameters to provide a default constructor for the class. In addition to the access methods setCode and getCode also define the methods scanner and printer . For test purposes these methods will simply output product data on screen or read the data of a product from the keyboard. The next step involves developing special cases of the Product class. Define two classes derived from Product PrepackedFood and FreshFood. In addition to the product data the PrepackedFood class should contain the unit price and the FreshFood class should contain a weight and a price per kilo as data members. In both classes define a constructor with parameters providing default-values for all data members. Use both the base and member initializer. Define the access methods needed for the new data members.Also redefine the methods scanner and printer to take the new data members into consideration. Test the various classes in a main function that creates two objects each of the types Product PrepackedFood and FreshFood. One object of each type is fully initialized in the object definition. Use the default constructor to create the other object.Test the get and set methods and the scanner method and display the products on screen. 520 .

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.