Guest User

Untitled

a guest
Jan 27th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.62 KB | None | 0 0
  1. package com.codegym.task.task06.task0621;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6.  
  7. /*
  8. Cat relations
  9.  
  10. */
  11.  
  12. public class Solution {
  13.     public static void main(String[] args) throws IOException {
  14.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  15.  
  16.         String gf,gm,f,m,s,d;
  17.         gf = reader.readLine();
  18.         gm=reader.readLine();
  19.         f=reader.readLine();
  20.         m=reader.readLine();
  21.         s=reader.readLine();
  22.         d=reader.readLine();
  23.            
  24.         System.out.println(catMother);
  25.         System.out.println(catDaughter);
  26.     }
  27.     public static class Father {
  28.         private String father;
  29.         Father(String father)
  30.         {
  31.             this.father = father;
  32.         }
  33.     }
  34.     public static class Mother {
  35.         public String mother;
  36.         Mother(String mother){
  37.             this.mother =mother;
  38.         }
  39.     }
  40.     public static class Cat {
  41.         private String name;
  42.         private Father father;
  43.         private Mother mother;
  44.  
  45.         Cat(String name,Father father,Mother mother) {
  46.             this.name = name;
  47.             this.father = father;
  48.             this.mother = mother;
  49.         }
  50.        
  51.        
  52.  
  53.         @Override
  54.         public String toString() {
  55.             if (father == null && mother==null)
  56.                 return "The cat's name is " + name + ", no mother "+", no father";
  57.             else if(father!=null && mother ==null)
  58.                 return "The cat's name is " + name + ", no mother ," + father.name + " is the father"+;
  59.         }
  60.     }
  61.  
  62. }
Add Comment
Please, Sign In to add comment