A 1 Question Oop

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Object Oriented Programming – Spring 2023

Assignment 01: Array, Methods, Classes, Objects, Constructors

Submission Date: 30th March, 2023

Submission Format: classes and object creation in A4 paper (hand written) + screenshots of
windows form application and submit in a compiled way.

1. Write a class Employee which contains a method called getNumberOfEmployees(). This method
should return the number of instances of the class (use constructor).

2. Create a class called Vector. The class Vector must contain 3 instance variables. Each instance variable
must be declared as private.
private double x;
private double y;
private double z;
a. public Vector(double xcoord, double ycoord, double zcoord)- This is the constructor of your vector
class. It should initialize 3 private instance variables, called x, y, z with the values of the input
variables, xcoord, ycoord, and zcoord respectively.
b. public double getX() This method should return the value of the instance variable x
c. public double getY() This method should return the value of the instance variable y
d. public double getZ() This method should return the value of the instance variable z
e. public Vector add(Vector v) This method should return a new Vector which is calculated by adding
this vector–i.e. the vector which is doing the behaviour–to the vector passed to it as a parameter.
f. public double computeMagnitude() This method should compute the magnitude of the vector.
One can compute the magnitude of a vector by summing the squares of all coordinates and taking
the square root.

g. public void normalize() This method should normalize the this vector. Note that this is the only
method which will change the value of the current vector instead of returning a new value. One
can normalize a vector by dividing each of a vector’s components by the magnitude of the vector.
3. Design Windows form application for following scenario.
4. Design Windows form application for following scenario.

Label
Output should be like this
Buttons

Paying Car No Pay Car Paying Cars: 15

No Paying Cars: 6

Show Total

5. Design Windows form application for following scenario.

You might also like