ChaseDream

标题: 英文~ [打印本页]

作者: 拆不散D大熊小熊    时间: 2020-9-26 05:44
标题: 英文~
Congratulations on reaching
20th century staples

[color=rgba(0, 0, 0, 0.45)]If you stroll somewhere, you walk there in a slow, relaxed way.



作者: 拆不散D大熊小熊    时间: 2020-10-6 07:49
We won't delve too deeply
An Excel sheet consists of cells. Each cell has its own unique identifier
Pascal is superior to Java.
Programming is no exception
we focus primarily on practice, which lets you progress as quickly as possible.
scratch that
Writing a program amounts to describing the various ways that objects can interact.  近乎等于
Games
Help
Subscriptions
Success stories
Chat
Forum
Articles
Friends
Messages
Activity
CodeGym

User Xi Yang
1
Teacher elly
Object interaction
Java Syntax
Level 2, Lesson 1
"Hi, Amigo. Today I'll tell you about a typical Java program. The big news is that every program written in Java consists of classes and objects."

"I already know what classes are. What are objects?"

"Let's start with an analogy. Suppose you want to build a small ship. You work on a design and then send the blueprint to a factory, where a ship will be assembled according to your design. Or a dozen ships, or as many ships as you want. My point is that dozens of identical ships can be made based on one blueprint."

"That's exactly how it works with Java."

"Java programmers are like design engineers, except instead of creating blueprints, they write classes. Ship parts are made based on blueprints, while objects are created based on classes."

"First, we write classes (make blueprints). Then, when the program is run, the Java machine creates objects based on these classes. It's exactly like how ships are built from a blueprint. One blueprint – many ships. The ships are different. They have different names and carry different cargo. But they are still similar. They all have an identical design, and are able to perform similar tasks."

"OK, I get your ship analogy. Could you give me a couple more to help me be sure I understand what you're saying?"

"Take, for example, bees..."

Object interaction - 1
"No, scratch that. I've had a bad experience with bees. Let's take ants."

"An ant colony is a good example of how objects interact. Any ant colony consists of three classes: the queen, soldiers, and worker ants. The number of ants in each class varies. Usually a colony only has one queen, dozens of soldiers, and hundreds of workers. Three classes, hundreds of objects. The ants follow strict rules as they interact with ants in their own class and ants that belong to other classes."

"This is the perfect example. A typical program works exactly like that. There is a main object that creates objects in all the classes. The objects interact with each other and with the external world. The objects' behavior is hardwired (programmed) internally."

"I don't quite get it. I mean, I don't get it at all."

"These two explanations are two sides of the same coin. The truth is somewhere in between. The first example (about blueprints and ships) shows us the connection between a class and its objects. It's a powerful analogy. The ant colony analogy demonstrates the relationship between objects, which are described by classes and exist only while a program is running."

"You mean we need to write classes for all objects used in a program, and then describe their interactions?"

"Yes, but it's easier than it sounds. In Java, while a program is running, all entities are objects. Writing a program amounts to describing the various ways that objects can interact. The objects simply call each other's methods and pass the required data to them."

"It's a little fuzzy, but I think I almost get it."





欢迎光临 ChaseDream (https://forum.chasedream.com/) Powered by Discuz! X3.3