Object Oriented Programming Assignment-Sheikh Hasiba -202411068011 (1)
Object Oriented Programming Assignment-Sheikh Hasiba -202411068011 (1)
Uml Code 1
#include <bits/stdc++.h>
class Loan {
private:
double annualInterestRate;
int numberOfYears;
double loanAmount;
string loanDate;
public:
annualInterestRate = rate;
numberOfYears = years;
loanAmount = amount;
// Get methods
return numberOfYears;
return loanAmount;
return loanDate;
// Set methods
annualInterestRate = rate;
numberOfYears = years;
loanAmount = amount;
loanDate = date;
};
int main() {
Loan myLoan;
cout << "Annual Interest Rate: " << myLoan.getAnnualInterestRate() << "%" << endl;
return 0; }
UML:2-BMI
Uml Code 2
#include <bits/stdc++.h>
class BMI {
private:
string name;
int age;
public:
// Constructor
name = personName;
age = personAge;
weight = personWeight;
height = personHeight;
return "Underweight";
return "Overweight";
else
return "Obese";
};
int main() {
BMI person;
person.setValue("John Doe", 25, 70.0, 1.75); // Name, Age, Weight (kg), Height (m)
cout << "BMI Details for " << person.getStatus() << ":" << endl;
UML:3-GeometricObject
Uml 3
#include <bits/stdc++.h>
class GeometricObject {
private:
string color;
bool filled;
string dateCreated;
public:
color = objColor;
filled = isFilled;
// Get color
return color;
return filled;
return dateCreated;
// Set color
color = newColor;
filled = fillStatus;
return 0.0;
return 0.0;
};
double width;
double height;
public:
};
private:
double radius;
public:
Circle(double r) : radius(r) {}
};
int main() {
rect.setValue("red", true);
cout << "Filled: " << (rect.isFilled() ? "Yes" : "No") << endl;
Circle circle(7.0);
circle.setValue("blue", false);
cout << "Filled: " << (circle.isFilled() ? "Yes" : "No") << endl;
return 0;
}
UML:4-Circle
UML 4
#include <bits/stdc++.h>
class Circle {
private:
double radius;
public:
// Default constructor
Circle() : radius(0.0) {}
Circle(double r) : radius(r) {}
// Color and filled are just placeholders; no need to store them for simplicity
void setRadius(double r) {
radius = r;
return 2 * radius;
};
int main() {
Circle c3(7.0, "red", true); // Circle with radius 7.0, color red, filled
return 0;
UML-5-Rectangle
UML 5
#include <bits/stdc++.h>
class Rectangle {
private:
double width;
double height;
public:
// Default constructor
void setWidth(double w) {
width = w;
return height;
void setHeight(double h) {
height = h;
};
int main() {
Rectangle r2(5.0, 10.0); // Rectangle with width 5.0 and height 10.0
Rectangle r3(7.0, 12.0, "blue", true); // Rectangle with width 7.0, height 12.0, color blue, filled
return 0;