20110508 Traffic Light Management system

Source: Internet
Author: User

First of all, according to the needs of the analysis, combined with object-oriented design, for traffic light management system, to determine the change in the lamp, when the car began to go, the first need to put it

To abstract, and the most important experience in cotton thread design is: Who owns the data and who provides the means to manipulate the data.

Create a road class, he's got a car. This attribute (ArrayList), and the Java concurrency Library that he uses, allows him to generate a car every second (since it uses internal classes, when the inner class accesses the properties of the external class, the implementation must be final, or use Class name. This. property name to access
One of the more important is when the lamp from red to green, he wants to inform the next to say which light is green, the next time to change, so cycle.
In addition, 12 traffic lights are designed as enumerations, each of which is an instance object of an enumeration, and a valid short line of code.

Some aspects of object-oriented design:


A typical case of object-oriented design
1, people on the blackboard to draw a circle

Objects: Person,blackboard,circle

Draw () Draw round This action is provided by WHO. Answer: Park
Because
Drae () {
X,y--> Radius This method has a center (x,y) Radius (RADIUS) that is the property of the garden.
}

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.