Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package animals;
- import java.util.ArrayList;
- import java.util.List;
- /**
- *
- * @author fmi
- */
- public class Person {
- private int age;
- private String name;
- private String sex = "mial";
- private HumanBrain brain= new HumanBrain(1400);
- // Ctr + Shift + I
- private ArrayList<HumanBrain> brains = new ArrayList<HumanBrain>();
- public Person(int age, String name) {
- this.age = age;
- this.name = name;
- }
- public int getAge() {
- return age;
- }
- public String getName() {
- return name;
- }
- public void setAge(int age) {
- this.age = age;
- }
- public void setName(String name) {
- this.name = name;
- }
- // inner class. Doesn't have static modifier
- private class HumanBrain{
- private double weight;
- private String sex = "femail";
- public HumanBrain(double weight) {
- this.weight = weight;
- }
- public String makeDecision() {
- if (weight > 1400) return "I am smart " + name + sex;
- else return "Dumm" + name + Person.this.sex;
- }
- }
- public void introduceYourSelf() {
- System.out.println("I am a person. I am " + age + " old. My name is " + name + "My brain tells me that I am " + brain.makeDecision());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement