0% found this document useful (0 votes)
18 views4 pages

Object Passing

The document outlines various class designs for a programming assignment, focusing on object-oriented concepts such as data members and member functions. It includes specifications for classes like Point, d2Point, Angle, Time, SortAlpha, Transpose, Combine, Matrix, Shifts, Adder, EqMat, and MatRev, each with unique functionalities related to geometric calculations, time management, sorting, and matrix operations. Each class requires a main function to demonstrate its capabilities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views4 pages

Object Passing

The document outlines various class designs for a programming assignment, focusing on object-oriented concepts such as data members and member functions. It includes specifications for classes like Point, d2Point, Angle, Time, SortAlpha, Transpose, Combine, Matrix, Shifts, Adder, EqMat, and MatRev, each with unique functionalities related to geometric calculations, time management, sorting, and matrix operations. Each class requires a main function to demonstrate its capabilities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ASSIGNMENT

OBJECT PASSING
CLASS XII

1)​ The coordinates of a point p on a two dimensional plane can be represented by p(x,
y) with x as the x- coordinate and y- coordinate. The coordinates of mid point of two
points p1(x1 ,y1) and p2(x2, y2) can be calculated as p(x, y) where:
X= (x1+ x2)/2
Y= (y1 + y2)/2​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​
Design a class Pointwith the following details:
Class Name​ ​ ​ ​ :​ Point
Data Members/Instance Variables​ :
x​ ​ :​ stores the x- coordinate
y​ ​ :​ stores the y- coordinate
Member Functions​ ​ ​ :
Point()​​ ​ ​ ​ :​ constructor to initialize x= 0, y=0
voidreadpoint()​ ​ ​ :​ Accept the coordinates x and y of a point.
Point midpoint(Point A, Point B)​ :​ calculates and returns the midpoint of two
points A and B​
void displaypoint()​ ​ ​ :​ displays the coordinates of a point.
Write the main function to create object of the class and call above member methods.

2)A class d2Point defines the coordinates of a point in a plane to calculate the distance
between two points. The details of the class are given below:
Class Name​ ​ ​ ​ :​ d2Point
Data Members/Instance Variables​ :
x, y​ ​ ​ ​ ​ :​ (double) to store the x and y
coordinates
Member Functions​ ​ ​ :
d2Point()​ ​ ​ ​ :​ default constructor
d2Point(double nx, double ny)​ :​ parameterized constructor to assign nx
to x, ny to y
double distance2d(d2Point b)​: ​ to return the distance between the point b and
the current point
Write the main function
3)A class Angle has been defined to add any two accepted Angles.
Angle A ​ : 16 Degree 35 minutes
Angle B ​ : 17 hours 45 minutes
Sum of Angles​: 34 hours 20 minutes
The details of the members of the class are given below:
Class Name​ ​ ​ ​ :​ Angle
Data Members/Instance Variables​ :
deg, min​ ​ ​ ​ :​ (integers) to store degree and minutes
Member Functions​ ​ ​ :
Angle()​​ ​ ​ ​ :​ default constructor
void getAngle()​ ​ ​ :​ to enter angle in degree and minutes
void printtime()​ ​ ​ :​ to display values of ‘deg’ and ‘min’ with
suitable headings
void sumAngle(Angle A1, Angle A2)​ :​ to add the Angles A1 and A2 and store
the resultant Angle ​ ​ ​ ​ ​ ​ ​ in current object.
Write the main function.
4) A class Time has been defined to add any two accepted time.
Time A​ : 6 hours 35 minutes
Time B ​ : 7 hours 45 minutes
Sum of time​ : 14 hours 20 minutes
The details of the members of the class are given below:
Class Name​ ​ ​ ​ :​ Time
Data Members/Instance Variables​ :
hrs, min​ ​ ​ ​ :​ (integers) to store hours and minutes
Member Functions​ ​ ​ :
Time()​ ​ ​ ​ ​ :​ default constructor
void gettime(int nh, int nm)​ ​ :​ to assign nh to hrs and nm to min
void printtime()​ ​ ​ :​ to display values of hrs and min with
suitable headings
Time sumtime(time t1, time t2)​ :​ to add the times given in the time
objects t1 and t2 and return it.
Write the main function.
5)A class SortAlpha has been defined to sort the words in the sentence in alphabetical order.
Example: Input: THE SKY IS BLUE Output: BLUE IS SKY THE
Some of the members of the class are given below:
Class name :​ SortAlpha
Data members/instance variable:
sent : ​ ​ to store a sentence
n:​ ​ ​ integer to store the number of words in a sentence
Methods/Member functions:
SortAlpha() :​ default constructor to initialise data members with legal initial value
void acceptsent() :​ to accept a sentence in UPPER CASE
void sort(SortAlpha P) : sorts the words of the sentence of object P in alphabetical order and
stores the sorted sentence in the current object
void display() : ​ display the original sentence along with the sorted sentence by
invoking the method sort()
Specify the class SortAlpha giving details of the constructor(), void acceptsent(), void
sort(SortAlpha) and void display(). Define a main() function to create an object and call the
functions accordingly to enable the task

6)A Matrix contains two dimensional integer array of order m × n. the maximum value
possible for both m and n is 20.Define a class Transpose as follows:​ ​ ​
​ ​ ​ ​ ​ [2009]​
Class name​ ​ ​ ​ :​ Transpose
Data Members/Instance Variable:
arr[][]​ ​ ​ ​ ​ :​ stores the matrix elements
m​ ​ ​ ​ ​ :​ integer to store the number of rows
n​ ​ ​ ​ ​ :​ integer to store the number of columns
Member functions:
Transpose()​ ​ ​ ​ :​ default constructor
Transpose (int mm, int nn)​ ​ :​ to initialize the size of the matrix m=mm and
n=nn
void fillarray()​ ​ ​ ​ :​ to enter the elements of the matrix
void Trans(Transpose A)​ ​ :​ to find the transpose of a given matrix of object
A and store it in ​ ​ ​ ​ ​ ​ ​ the current object.
void display()​ ​ ​ ​ :​ display the array elements in matrix form
Define the main method.
7)Define a class Combine is declared as follows:​ ​ ​ ​ ​ [2012]
Class name​ ​ ​ ​ :​ Combine
Data Members/Instance Variable:
arr[]​ ​ ​ ​ ​ :​ integer array
size​ ​ ​ ​ ​ :​ size of the array
Member functions:
Combine(int nn)​ ​ ​ :​ parameterize constructor to assign size=nn
void input()​ ​ ​ ​ :​ to accept the array elements
void sort()​ ​ ​ ​ :​ sort the elements of combined array in asc​
​ ​ ​ ​ ​ ​ ​ using selection sort technique.
void mix(Combine A, Combine B)​ :​ combine the parameterized object arrays and
stores the result in the current object array along with duplicate elements, if any
void display()​ ​ ​ ​ :​ displays the array elements
Define the main method.

8) A Matrix contains two dimensional integer array of order m × n. the maximum value
possible for both m and n is 25. Design a class Matrix as follows:​ ​ ​ [2013]​
Class name​ ​ ​ ​ :​ Matrix
Data Members/Instance Variable:
arr[][]​ ​ ​ ​ ​ :​ stores the matrix elements
m​ ​ ​ ​ ​ :​ integer to store the number of rows
n​ ​ ​ ​ ​ :​ integer to store the number of columns
Member functions:
Matrix(int mm, int nn)​ ​ :​ to initialize the size of the matrix m=mm and
n=nn
void fillarray()​ ​ ​ ​ :​ to enter the elements of the matrix
Matrix SubMat(Matrix A)​ ​ :​ subtract the current object from the matrix of
parameterized ​ ​ ​ ​ ​ ​ ​ object.
void display()​ ​ ​ ​ :​ display the matrix elements
Define the main method.
9A class Shifts contains a two dimensional integer array of order ( m*n) where the maximum
values of both m and n is 5. Design the class Shifts to shifts to shuffle the matrix (i.e. the first
row becomes the last, the second row becomes the first and so on). The details of the
members of the class are given below:​ [2016]

Class name​ ​ ​ ​ :​ Shifts


Data Members/Instance Variable:
mat[][]​​ ​ ​ ​ :​ stores the array elements
m​ ​ ​ ​ ​ :​ integer to store the number of rows
n​ ​ ​ ​ ​ :​ integer to store the number of rows

Member functions:
Shifts(int mm, int nn)​ ​ ​ :​ parameterized constructor
void input()​ ​ ​ ​ :​ enter the array elements
void cyclic (Shifts P)​ ​ ​ :​ enables the matrix of the object p to shift each
row upwards in a cyclic manner and store the resultant matrix in the current object
void show()​ ​ ​ ​ :​ displat the array elements in matirx form.
Define the main method.

10.A class Adder has been defined to add any two accepted time.​ ​ ​ [2017]
Time A ​ : 6 hours 35 minutes
Time B ​ : 7 hours 45 minutes
Sum of time​ : 14 hours 20 minutes
The details of the members of the class are given below:
Class Name​ ​ ​ ​ :​ Adder
Data Members/Instance Variables​ :
a[]​ ​ ​ ​ ​ :​ (integers) array to hold two elements
(hours and minutes)
Member Functions​ ​ ​ :
Adder()​ ​ ​ ​ :​ constructor to assign 0 to the array
elements
void readtime()​ ​ ​ :​ to enter the elements of the array
void addtime(Adder X, Adder Y)​ :​ adds the time of parameterized objects
X and Y and stores ​ ​ ​ ​ ​ ​ ​ the sum in the
current calling object.
void disptime()​ ​ ​ :​ display te array elements with an
appropriate ​ ​ ​ ​ ​ ​ ​ ​ message (i.e.
hours= and minutes=)
Write the main function.

11Design a class EqMat having following details:​ ​ ​ ​ ​ [2018]


Class name​ ​ ​ ​ :​ EqMat
Data Members/Instance Variables​
a[][]​ ​ ​ ​ ​ :​ to store integer elements
m​ ​ ​ ​ ​ :​ to store the number of rows
n​ ​ ​ ​ ​ :​ to store the number of columns
Member Functions​
EqMat(int mm, int nn)​ ​ :​ parameterized constructor to initialize
the members ​​ ​ ​ ​ ​ ​ ​ m=mm and n=nn
void input()​ ​ ​ ​ :​ To input array elements
int check(EqMat P, EqMat Q)​ ​ :​ checks if the parameterized object P and
Q are equal and ​ ​ ​ ​ ​ ​ ​ ​ returns 1 if true,
otherwise returns 0
void print()​ ​ ​ ​ :​ displays the array elements.
Write the main function.

12 Class name​​ ​ :​ MatRev


arr[][]​ ​ ​ ​ :​ to store integer elements
m​ ​ ​ ​ :​ to store number of rows
n​ ​ ​ ​ : ​ to store the number of columns
Member functions:
MatRev(int mm ,int nn)​ :​ parameterized constructor to initialize the data
members m=mm and ​ ​ ​ ​ ​ n=nn
void fillarray()​ ​ ​ :​ to enter elements in the array
int reverse(int x)​ ​ :​ returns the reverse of the number x
void revMat(MatRev p)​ :​ reverse each element of the array of the parameterized
object and store ​ ​ ​ ​ ​ ​ it in the array of the current
object.
void show()​ ​ ​ :​ display the array elements in matirx form.

You might also like