For my homework I had to create a program in C# which has a class called "patient", as so:
class patient
{
private string name;
private int age;
private double weight;
private double height;
public patient()
{
name = "";
age = 0;
weight = 0;
height = 0;
}
public patient(string newName, int newAge, double newWeight, double newHeight)
{
name = newName;
age = newAge;
weight = newWeight;
height = newHeight;
}
public double bmi()
{
return weight / Math.Pow(height, 2);
}
public bool obese()
{
if (bmi() > 27 && age < 40)
return true;
else if (bmi() > 30 && age >= 40)
return true;
else
return false;
}
public void printDetails()
{
Console.WriteLine("Name: " + name);
Console.WriteLine("Age: " + age);
Console.WriteLine("Weight: " + weight + "kg");
Console.WriteLine("Height: " + height + "m");
Console.WriteLine("BMI: " + bmi());
if (obese())
Console.WriteLine("Patient is obese");
else
Console.WriteLine("Patient is not obese.");
}
And the last part of the question says: Write a method which records recent patients entered along with their obesity diagnosis into an ArrayList. It should record the five most recent entries and their diagnosis.
Array lists cannot be multi-dimensional, but the question is looking me to record both the obesity diagnosis and the actual patient.
I had thought about storing the object in the array list, but I'm not sure if that is what the question wants. Any ideas?