Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- public class Person {
- String name;
- int age;
- long personalNumber;
- boolean isWoman;
- double weight;
- Person[] friends;
- double money;
- Car car;
- Person(){
- this.age = 0;
- this.weight = 4.0;
- }
- Person(String name, long personalNumber, boolean isWoman){
- this();
- this.name = name;
- this.personalNumber = personalNumber;
- this.isWoman = isWoman;
- friends = new Person[3];
- }
- void eat(){
- System.out.println("Eating...");
- }
- void walk(){
- System.out.println(name + " is walking");
- }
- void growUp(){
- age++;
- }
- void drinkWater(double liters){
- if(liters > 1){
- System.out.println("This is too much water!!!");
- }
- else{
- System.out.println(name + " is drinking " + liters + " water.");
- }
- }
- void buyCar(Car car){
- if(this.money > car.price){
- this.car = car;
- }
- }
- double sellCarForScap(){
- this.car = null;
- return this.money += this.car.calculateCarPriceForScrap(10.0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement