Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class person
- {
- private string name;
- private int age;
- private double height;
- private double weight;
- public person( string newName, int newAge, double newHeight, double newWeight)
- {
- name = newName;
- age = newAge;
- height = newHeight;
- weight = newWeight;
- }
- public person()
- {
- name = "no name";
- age = 0;
- height = 0.50;
- weight = 3.200;
- }
- public override string ToString()
- {
- return name + "," + age + "år" + height + "m" + weight + "kg";
- }
- public string getName()
- {
- return name;
- }
- public void setName (string newName)
- {
- name = newName;
- }
- public int getAge()
- {
- return age;
- }
- public void setAge (int newAge)
- {
- if (newAge > 120)
- newAge = 0;
- age = newAge;
- }
- public double getHeight()
- {
- return height;
- }
- public void setHeight (double newHeight)
- {
- if (newHeight < 0 || newHeight > 2.50)
- {
- Console.WriteLine("højden skal være mellem 0 og 2.5 meter");
- }
- else height = newHeight;
- }
- public double getWeight()
- {
- return weight;
- }
- public void setWeight (double newWeight)
- {
- }
- public bool isAdult()
- {
- if (age >= 18 )
- {
- return true;
- }
- else return false;
- }
- public bool isChild()
- {
- if (age < 15)
- {
- return true;
- }
- else return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement