Would the below be correct for the following statement. “A man has a best friend who is a dog.”
public class Mann {
private BestFriend dog;
//etc
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Looks like Dog should by type, because man can have other “type of best friend”:
Update
Most close to real-live implementation will look like:
This way one can express friend relationships between any entities. Common base class is not required. You only need implement
Friendinterface.