2013年9月15日星期日

oo ideological programming ? ? ? ? ? ? ? ? ? ? ?

Pharaoh and the talk of the town a couple . Pharaoh is a university professor , talk of the town is an accountant , and their parents are alive . Pharaoh and the talk of the town has a son, 15 years old , and in secondary school. Pharaohs sometimes play tai chi, talk of the town sometimes go part-time lectures . With the idea of ​​OO describe their relationship
------ Solution -------------------------------- ------------
so described can do

------ Solution ------- -------------------------------------
old topic, why not try Baidu Look . http://bbs.csdn.net/topics/390537300
----- - Solution --------------------------------------------
Interface ; Person {}
Interface Man {
Person fuck (Woman woman);
}
Interface Woman {
Person fuckedBy (Man man);
}

class Wang implements Man {
@ Override
public Person fuck (Woman woman) {
if (woman instanceof Li)
return new ChildWang ();
return null;
}
}

class Li implements Woman {
@ Override
public Person fuckedBy (Man man) {
}
------ Solution ------------------------------- -------------
look here
------ For reference only ---------------------------------------
this is the idea of ​​object -oriented description of the ! ! ! ! !
------ For reference only ---------------------------------------

java interview questions , was written .
------ For reference only -------------------------------------- -

he was so , write code describe
------ For reference only ---------------------- -----------------
" husband and wife ", " their parents are alive ." ---- I do not know how expressed
I was a novice vegetables , the first to write that stuff , before all COPY

class Person {
private Gender gender;
private int age;

}

public enum Gender {
M,
F
}

class Parent extends Person {
private String job;
private String hobby;
private String part_time_job;

}

class Child extends Person {
private String school;
Parent mother, father;

}



public class MainApp {
Parent wang = new Parent ();
Parent li = new Parent ();
Child wangson = new Child ();

public static void main (String [] args) {
wang.gender = Gender.M;
wang.job = " university professor " ;
wang.hobby = " shadow boxing " ;

li.job = " accounting " ;
li.part_time_job = " lectures " ;
li.gender = Gender.F;

wangson.father = wang;
wangson.mather = li;
wangson.age = 15;
wangson.school = " middle school" ;
wangson.gender = Gender.M;
}
}

------ For reference only -------------------------------- -------
wangson.father = wang;
wangson.mather = li;

whether express the Pharaoh and talk of the town a couple ?
------ For reference only -------------------------------------- -

theoretically can only show you this formula Pharaoh and talk of the town there is a common son , can not explain the couple .
Pharaoh classes can be built
public class PersonWang extends Person {
Parent parent ;/ / parent object which contains two people , his father, his mother
Child child ;/ / child object which contains two people , his father, his mother
Wife wife ;/ / wife object which contains a man , his wife
Job job ;/ / job object , place of work , nature , etc.
/ / Method: play ball
}
------ For reference only --------------------------------- ------

------ For reference only --------------------------------------- < br>
only show you this equation theoretically Pharaoh and talk of the town there is a common son , can not explain the couple .   
Pharaoh classes can be built   
public class PersonWang extends Person {   
Parent parent ;/ / parent object which contains two people , his father, his mother   
Child child ;/ / child object which contains two people , his father, his mother   
Wife wife ;/ / wife object which contains a man , his wife   
Job job ;/ / job object , place of work , nature , etc.   
/ / Method: play ball   
}  


but also for old Wang class ? Do you want a few NEW Pharaoh ?

why there is no master shot ? Too simple ?
------ For reference only -------------------------------------- -

theoretically can only show you this formula Pharaoh and talk of the town there is a common son , can not explain the couple .   
Pharaoh classes can be built   
public class PersonWang extends Person {   
Parent parent ;/ / parent object which contains two people , his father, his mother   
Child child ;/ / child object which contains two people , his father, his mother   
Wife wife ;/ / wife object which contains a man , his wife   
Job job ;/ / job object , place of work , nature , etc.   
/ / Method: play ball   
}  
" play ball ", etc. in the actual development can no longer be placed in which a JavaBean !
------ For reference only -------------------------------------- -
http://bbs.csdn.net/topics/390536618 complete solution
------ For reference only -------------- -------------------------



??? no answer
------ For reference only ---------------------------- -----------
focus on their relationship a couple .
------ For reference only ---------------- -----------------------
pain free eggs , right
------ For reference only ------ ---------------------------------

+1
Oh Oh
------ For reference only ------------------------------ ---------


------ For reference only ---------------------------------------
admire the landlord ideas
------ For reference only ---------------------------------------

  
  
??? no answer  

http://bbs.csdn.net/topics/390537300
------ For reference only --------------------- ------------------
Interface Person {}
Interface Man {
Person fuck (Woman woman);
}
Interface Woman {
Person fuckedBy (Man man);
}

class Wang implements Man {
@ Override
public Person fuck (Woman woman) {
if (woman instanceof Li)
return new ChildWang ();
return null;
}
}

class Li implements Woman {
@ Override
public Person fuckedBy (Man man) {
if (man instanceof Wang)
return new ChildWang ();
return new Person () {};
}
}

class ChildWang implements Man {
@ Override
public Person fuck (Woman woman) {
}
}
------ For reference only --------------------------------- ------
this sb forum, your posts can not be changed , ctrl + enter for mac users too easy to inadvertently the

made ​​a mistake a lot before . Key point here is to write the remaining capacity ah ah what position do not care for

Interface Person { }
Interface Man {
  Person fuck (Woman woman);
}
Interface Woman {
  Person fuckedBy (Man man);
}

class Wang implements Man {
  @Override
  public Person fuck (Woman woman) {
    if (woman instanceof Li)
      return new ChildWang();
    return null;
  }
}

class Li implements Woman {
  @Override
  public Person fuckedBy (Man man) {
    if (man instanceof Wang)
      return new ChildWang();
    return new Person() {};
  }
}

class ChildWang implements Man {
  @Override
  public Person fuck (Woman woman) {
    return new Person() {};
  }
}

------ For reference only ----------------------------------- ----

Niubi
------ For reference only ---------------------------------------

------ For reference only ------ ---------------------------------
21L god replies
------ For reference only ---------------------------------------

Baidu did not looking to play
------ For reference only ------------------------------------ ---
21L Intuit talented

没有评论:

发表评论