Head first C # Chinese Version Chapter 1 Review and foresight page533

Source: Internet
Author: User

 

Go of Honeycomb
() Method



We give flower
Class writes
Go
() Method,
Bee
Class also writes
Go
() Method (although some code should be added ). Below is
Hive
Class
Go
() Method:



 

Unfortunately, this is not realistic. Most of the time, there is no time for young bees to grow. We don't have a queenbee
Class, but let's assume that when honey is enough, there will be a chance to create a young bee. We can write it down as follows:



 

 

Q: How many young bees can be created in a beehive?


A: It's okay now --
Of course, this is not realistic. Later we will come back and add constraints to allow a certain number of bees to exist in the beehive at the same time.



Q: We cannot change random.
Is the instance assigned to a class attribute? Instead of passing it as a parameter
Addbee
() Method?



A: Yes. In this way, addbee
You can use the attribute value instead of the parameter. There is no definite answer to this question. As you like.



Q: I still don't know these go
() How to call the method.



A: It doesn't matter. We are about to explain this. However, first we need a class -- World
It manages everything in the beehive, as well as bees and even flowers.

 





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.