Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package main;
  2.  
  3. public class Person {
  4.  
  5. String name;
  6. int age;
  7. long personalNumber;
  8. boolean isWoman;
  9. double weight;
  10. Person[] friends;
  11. double money;
  12. Car car;
  13.  
  14. Person(){
  15. this.age = 0;
  16. this.weight = 4.0;
  17. }
  18. Person(String name, long personalNumber, boolean isWoman){
  19. this();
  20. this.name = name;
  21. this.personalNumber = personalNumber;
  22. this.isWoman = isWoman;
  23. friends = new Person[3];
  24. }
  25. void eat(){
  26. System.out.println("Eating...");
  27. }
  28. void walk(){
  29. System.out.println(name + " is walking");
  30. }
  31. void growUp(){
  32. age++;
  33. }
  34. void drinkWater(double liters){
  35. if(liters > 1){
  36. System.out.println("This is too much water!!!");
  37. }
  38. else{
  39. System.out.println(name + " is drinking " + liters + " water.");
  40. }
  41. }
  42. void buyCar(Car car){
  43.  
  44. if(this.money > car.price){
  45. this.car = car;
  46. }
  47. }
  48. double sellCarForScap(){
  49. this.car = null;
  50. return this.money += this.car.calculateCarPriceForScrap(10.0);
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement