B.Tech. (I) - ICP-132 (2008) Assignment 6 Level 0 ------- 1. Make a class called "point" with two integer data members x and y. Show how to create and use two points p1 and p2. 2. Create a student record class "st_rec" that has the following data members: SR No., Name, marks in ICP, SDC, EDC, PHY, MAT and CSL, and Semester grade. Show how to use it. 3. Create a "human" class with private data members Age and Salary and public data members Father and Mother. Show how to set the values of Age and Salary using a constructor. Level 1 ------- 1. Using the Point class as mentioned above, write a function to compute distance between the points p1 and p2. 2. In the class "st_rec" as above, add a method that computes grade based on the total marks as follows if ( failed in any subject ) grade = "F" else if ( total < 40% ) grade ="F" else if ( total < 50% ) grade ="D" else if ( total < 60% ) grade ="C" else if ( total < 70% ) grade ="B" else if ( total < 80% ) grade = "B+" else if ( total < 90% ) grade = "A" else grade = "A+" 3. Write methods to see and modify Age and Salary in the class "human". Level 2 ------- 1. Create a class p4 with which can store 4 points (x1,y1) through (x4,y4). Write the following methods. dist: prints distance between first 2 points angle: prints angle between first 3 points area: finds area of the quadilateral enclosed by the 4 points closest: finds the point closest to origin 2. Write a class "Hello" with a method "helo" that prints "Hello!". It should also have a method "count" that gives the number of times the method "helo" was called. No other public data member or public method is allowed apart from "helo" and "count". 3. Create a class "Poll" that has a question "Q" and methods "yes", "no" and "results". The following rules are to be followed: 1. The programmer should be able to vote using "yes" or "no" 2. Once "results" method is called, results are shown. 3. After results are shown, "yes" and "no" methods will not change results and an error message is printed that the poll is over! Level 3 ------- Read operator overloading on classes, at least for '<'. See "Sample Code" in the Wiki. 1. Create a vector of objects of class "points" and put 5 objects. Sort the objects (points) as per the following rule: if ( x1 < x2 ) p1 < p2 else if ( y1 < y2 ) p1 < p2 else p1 > p2 2. Create an class with a list as a data member. Add two objects where addition is defined as sum of corresponding list elements. Hence if ob1 has a list <1, 2> and ob2 <7, 5, 4> then the result is ob3=ob1+ob2 where ob3 has a list <8, 7, 4>. Missing elements are treated as zero as in the case of the third element. 3. Create a class "Matrix" that can store a nxm matrix where n and m are user specified. Define an operator '*' so that the result is matrix multiplication.