B.Tech. (I) - ICP-132 (2008) Assignment 8 Level 0 ------- Implement all the examples for exception handling given in Balaguruswamy. Level 1 ------- 1. Given the following class, write a program to construct and use class 'line' with method to find distance. Class line should also find the slope, but the slope should not be accessible to user (ie, should not be public)! You can have your own data members and methods under private, protected and other placed as indicated below, but the public members cannot be increased. class line { private: protected: public: int x; int y; int dist() { } }; 2. Conisder the class 'movie' given below as a base class. Use it to construct two derived classes, 'bollywood' and 'hollywood'. Each has a data member 'certificate'. The values that can be accepted for certificate are 'U', 'U/A' and 'A' for bollywood and 'G', 'PG' and 'PG-13' for hollywood. User should be able to assign any of the above ceritificate to a movie but nothing else. If no valid certificate is available 'N/A' is to be the default value. Write a program that uses such classes. 3. Create the base class 'country' and derived classes 'monarchy' and 'democracy' with the following restrictions: class country { public: int population; int area; int no_of_states; }; class monarchy { public: string king; string queen; string minister; }; class democracy { public: string president; string vice_president; string prime_minister; }; Show how to use these to access all the members of the derived classes. Level 2 ------- 1. Create a derived class ind_mov that uses both democracy class and bollywood class. Show how to use it to get various information about India and its movies. 2. Create a derived class 'y_intercept' using class 'line' as a base class and the slope available in the 'line'. Given the two points, create a public method 'c' that returns the y-intercept. 3. Create two classes 'read' and 'copy' as shown below. Use them to open a given file name and copy it to another file. The file names are given by the user. Class 'copy' must inherit 'read' to complete its task. Is it necessary that 'read' class needs to be inherited to do the job even if it is mandatory to use 'read'? class read { private: protected: public: string ip_file; void read_file(string fname) { } }; class copy : { private: protected: public: string ip_file; void copy_file(string fname) { } }; 4. Create class 'two_lines' using class 'line'. It should have a bool returning method 'if_intersect' that returns true if the two lines intersect and false otherwise. 5. Inheriting the class copy, create a class 'file_class' that can be used to create, append and overwrite files. 6. Create a class 'state' which have list of states in a country along with the information on the state capitol and population. Create a class from this called 'country' that holds the information about states of various countries.