亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch3.htm

?? Java游戲開發(fā)
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
<HTML>

<HEAD>
   <TITLE>Chapter 3 -- Object-Oriented Programming with Java</TITLE>
   <META>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#CE2910">
<H1><FONT COLOR=#FF0000>Chapter 3</FONT></H1>
<H1><B><FONT SIZE=5 COLOR=#FF0000>Object-Oriented Programming with Java</FONT></B>
</H1>
<P>
<HR WIDTH="100%"></P>
<P>
<H3 ALIGN=CENTER><FONT COLOR="#000000"><FONT SIZE=+2>CONTENTS<A NAME="CONTENTS"></A>
</FONT></FONT></H3>

<UL>
<LI><A HREF="#WhatIsOOP" >What Is OOP?</A>
<UL>
<LI><A HREF="#Objects" >Objects</A>
<LI><A HREF="#Classes" >Classes</A>
<LI><A HREF="#Encapsulation" >Encapsulation</A>
<LI><A HREF="#Messages" >Messages</A>
<LI><A HREF="#Inheritance" >Inheritance</A>
</UL>
<LI><A HREF="#OOPandGames" >OOP and Games</A>
<LI><A HREF="#JavaandOtherOOPLanguages" >Java and Other OOP Languages</A>
<LI><A HREF="#Summary" >Summary</A>
<LI><A HREF="#QA" >Q&amp;A</A>
<LI><A HREF="#Workshop" >Workshop</A>
<UL>
<LI><A HREF="#Quiz" >Quiz</A>
<LI><A HREF="#Exercises" >Exercises</A>
</UL>
</UL>
<HR>
<P>
<I>Object-oriented programming</I> (OOP) is a programming paradigm
that is fundamentally different from traditional procedural programming
styles. It is centered around the concept of objects-programming
constructs that have both properties and the procedures for manipulating
those properties. This approach models the real world much more
closely than conventional programming methods and is ideal for
the simulation-type problems commonly encountered in games.
<P>
You're probably already aware that Java is an object-oriented
language, but you might not fully understand what that means.
To successfully use Java to write Internet games, you need to
embrace object-oriented programming techniques and design philosophies.
The goal of today's lesson is to present the conceptual aspects
of object-oriented programming as they relate to Java. By the
end of today's lesson, you will fully understand what OOP means
to Java and maybe even have some new buzz words to share with
your friends! More important, you will gain some insight into
why the OOP paradigm built into Java is a perfect match for game
programming.
<P>
The following topics are covered in today's lesson:
<UL>
<LI>What is OOP?
<LI>OOP and games
<LI>Java and other OOP languages
</UL>
<H2><A NAME="WhatIsOOP"><B><FONT SIZE=5 COLOR=#FF0000>What Is
OOP?</FONT></B></A></H2>
<P>
If you've been anywhere near the computer section of a bookstore
or picked up a programming magazine in the last five years, you've
certainly seen the hype surrounding object-oriented programming.
It's the most popular programming technology to come about in
a long time, and it all revolves around the concept of an object.
The advent of Java has only served to elevate the hype surrounding
OOP. You might wonder what the big deal is with objects and object-oriented
technology? Is it something you should be concerned with, and
if so, why? Is it really that crucial when working with Java?
If you sift through the hype surrounding the whole object-oriented
issue, you'll find a very powerful technology that provides a
lot of benefits to software design.
<P>
But the question still remains: What is OOP? OOP is an approach
to programming that attempts to bridge the gap between problems
in the real world and solutions in the computer programming world.
Prior to OOP, a conceptual stumbling block always existed for
programmers when trying to adapt the real world into the constraints
imposed by a traditional programming language. In the real world,
people tend to think in terms of &quot;things,&quot; but in the
pre-OOP programming world  people have been taught to think in
terms of blocks of code (procedures) and how they act on data.
These two modes of thinking are very different from each other
and pose a significant problem when it comes to designing complex
systems that model the real world. Games happen to be very good
examples of complex systems that often model the real world.
<P>
OOP presents an approach to programming that allows programmers
to think in terms of objects, or things, much like people think
of things in the real world. Using OOP techniques, a programmer
can focus on the objects that naturally make up a system, rather
than trying to rationalize the system into procedures and data.
The OOP approach is a very natural and logical application of
the way humans already think.
<P>
The benefits of OOP go beyond easing the pain of resolving real
world problems in the computer domain. Another key issue in OOP
is code reuse, when you specifically design objects and programs
with the goal of reusing as much of the code as possible, whenever
possible. Fortunately, it works out that the fundamental approaches
to OOP design naturally encourage code reuse, meaning that it
doesn't take much of an extra effort to reuse code after you employ
standard OOP tactics.
<P>
The OOP design approach revolves around the following major concepts:
<UL>
<LI>Objects
<LI>Classes
<LI>Encapsulation
<LI>Messages
<LI>Inheritance
</UL>
<H3><A NAME="Objects"><B>Objects</B></A></H3>
<P>
<I>Objects</I> are bundles of data and the code, or procedures,
that act on that data.
<P>
The procedures in an object are also known as <I>methods</I>.
The merger of data and methods provides a means of more accurately
representing real-world objects. Modeling a real-world problem
through traditional programming constructs, without objects, requires
a significant logical leap. Objects, on the other hand, enable
programmers to solve real-world problems in the software domain
much more easily and logically.
<P>
As evident by the name, objects are at the heart of object-oriented
technology. To understand how software objects are beneficial,
think about the common characteristics of all real-world objects.
Lions, cars, and calculators all share two common characteristics:
state and behavior.
<P>
The <I>state</I> of an object is the condition that the object
is in, as defined by its attributes.
<P>
The <I>behavior</I> of an object is the collection of actions
that the object can take.
<P>
For example, the state of a lion might include color, weight,
and whether the lion is tired or hungry. Lions also have certain
behaviors such as roaring, sleeping, and hunting. The state of
a car includes the current speed, the type of transmission, whether
it is two- or four-wheel-drive, whether the lights are on, and
the current gear, among other things. The behaviors for a car
include turning, braking, and accelerating.
<P>
Just like real-world objects, software objects possess two common
characteristics: state and behavior. To relate this back to programming
terms, the <I>state</I> of an object is determined by its data
and the <I>behavior</I> of an object is defined by its methods.
By making this connection between real-world objects and software
objects, you begin to see how objects help bridge the gap between
the real world and the world of software living inside your computer.
<P>
Because software objects are modeled after real-world objects,
you can more easily represent real-world objects in object-oriented
programs. You could use the lion object to represent a real lion
in an interactive software zoo. Similarly, car objects would be
very useful in a racing game. However, you don't always have to
think of software objects as modeling physical real-world objects;
software objects can be just as useful for modeling abstract concepts.
For example, the standard Java API provides a thread object that
represents a stream of execution in a multithreaded program.
<P>
Figure 3.1 shows a visualization of a Java software object, including
the primary components and how they relate.
<P>
<A HREF="f3-1.gif" ><B>Figure 3.1 : </B><I>A software object.</I></A>
<P>
The software object in Figure 3.1 clearly shows the two primary
components of an object: data and methods. The figure also shows
some type of communication, or access, between the data and the
methods. Additionally, it shows how messages are sent through
the methods, which result in responses from the object. You'll
learn more about messages later today in the &quot;Messages&quot;
section.
<P>
The data and methods within an object express everything that
the object knows (state), along with what all it can do (behavior).
A software object modeling a real-world car would have variables
(data) that indicate the car's current state: it's traveling at
75 mph, it is in 4th gear, and the lights are on. The software
car object would also have methods that enable it to brake, accelerate,
steer, change gears, and turn the lights on and off. Figure 3.2
shows what a Java car object might look like.
<P>
<A HREF="f3-2.gif" ><B>Figure 3.2 : </B><I>A car object.</I></A>
<P>
In both Figures 3.1 and 3.2 you probably noticed the line separating
the methods from <BR>
the data within the object. This line is a little misleading,
because methods have full access to the data within an object.
The line is there to illustrate the difference between the visibility
of the methods and the data to the outside. In this sense, an
object's visibility refers to what parts of the object another
object has access to. Because object data defaults to being invisible,
or inaccessible to other objects, all interaction between objects
must be handled via methods. This hiding of data within an object
is called <I>encapsulation</I>.
<H3><A NAME="Classes"><B>Classes</B></A></H3>
<P>
Throughout this discussion of object-oriented programming, you've
only dealt with the concept of an object already existing in a
system. You might be wondering how objects get into a system in
the first place. This question brings you to the most fundamental
structure in object-oriented programming: the class.
<P>
A <I>class</I> is a template or prototype that defines a type
of object.
<P>
A class is to an object what a blueprint is to a house. Many houses
can be built from a single blueprint; the blueprint outlines the
makeup of the houses. Classes work exactly the same way, except
that they outline the makeup of objects.
<P>
In the real world, there are often many objects of the same kind.
Using the house analogy, there are many different houses around
the world, but as houses they all share common characteristics.
In object-oriented terms, you would say that your house is a specific
instance of the class of objects known as houses.
<P>
An <I>instance</I> of a class is an object that has been created
in memory using the class as a template. Instances are also sometimes
referred to as <I>instantiated objects</I>.
<P>
All houses have states and behaviors in common that define them
as houses. When a builder starts building a new development of
houses, he or she typically will build them all from a set of
blueprints. It wouldn't be as efficient to create a new blueprint
for every single house, especially when there are so many similarities
shared between each one. The same thing applies in object-oriented
software development; why rewrite a lot of code when you can reuse
code that solves similar problems?
<P>
In object-oriented programming, as in construction, it's also
common to have many objects of the same kind that share similar
characteristics. And like the blueprints for similar houses, you
can create blueprints for objects that share certain characteristics.
What it boils down to is that classes are software blueprints
for objects.
<P>
As an example, the class for the car object discussed earlier
would contain several variables representing the state of the
car, along with implementations for the methods that enable the
driver to control the car. The state variables of the car remain
hidden underneath the interface. Each instance, or instantiated
object, of the car class gets a fresh set of state variables.
This brings you to another important point: When an instance of
an object is created from a class, the variables declared by that
class are allocated in memory. The variables are then modified
via the object's methods. Instances of the same class share method
implementations but have their own <I>object data</I>. Classes
can also contain class data.
<P>
<I>Object data</I>, or <I>instance data</I>, is the information
that models an object's state. Each object in memory has its own
set of instance data, which determines what state the object is

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美高清视频一二三区| 国产91丝袜在线播放九色| 精品视频一区二区三区免费| 中文字幕亚洲精品在线观看| 99久久99久久精品国产片果冻| 1区2区3区精品视频| 欧美亚洲国产一卡| 日日夜夜精品视频天天综合网| 欧美一区二区在线免费观看| 国内成+人亚洲+欧美+综合在线 | 中文字幕av不卡| av中文字幕亚洲| 一区二区三区**美女毛片| 欧美精品日日鲁夜夜添| 久久99国产精品久久99果冻传媒| 精品国产伦一区二区三区观看方式| 丰满少妇在线播放bd日韩电影| 国产精品狼人久久影院观看方式| 欧美亚一区二区| 久久爱www久久做| 国产精品人妖ts系列视频| 一本高清dvd不卡在线观看| 视频一区视频二区中文| 久久精品视频免费| 欧美午夜电影一区| 国产毛片一区二区| 亚洲精品国久久99热| 欧美一级国产精品| 不卡高清视频专区| 日本人妖一区二区| 中文字幕在线视频一区| 777久久久精品| av在线播放一区二区三区| 日韩高清一区在线| 日本一区二区三级电影在线观看| 欧美亚洲国产一区二区三区va | 国精产品一区一区三区mba桃花 | 91精品国产综合久久久久久漫画 | 色综合亚洲欧洲| 蜜桃av噜噜一区二区三区小说| 中文字幕中文字幕在线一区| 日韩一级成人av| 色狠狠一区二区三区香蕉| 国产中文一区二区三区| 亚洲国产成人av| 国产精品网站在线| 日韩欧美一级在线播放| 91福利区一区二区三区| 夫妻av一区二区| 日本亚洲电影天堂| 亚洲综合色视频| 国产精品美女视频| 精品少妇一区二区三区视频免付费| 一本到高清视频免费精品| 国产成人免费视频一区| 麻豆一区二区在线| 亚洲一区二区四区蜜桃| 亚洲欧洲精品一区二区三区| 欧美不卡在线视频| 欧美电影影音先锋| 欧美三级在线播放| 欧洲一区二区三区在线| 91啪在线观看| 99久久久久免费精品国产| 国产精品羞羞答答xxdd| 国产在线观看免费一区| 免费在线视频一区| 日韩精品视频网站| 亚洲国产精品精华液网站| 亚洲男人的天堂在线aⅴ视频| 国产精品免费视频观看| 国产免费成人在线视频| 国产午夜亚洲精品不卡| 国产亚洲人成网站| 国产日本亚洲高清| 久久精品亚洲国产奇米99| 精品91自产拍在线观看一区| 日韩精品一区二区三区蜜臀| 日韩欧美区一区二| 久久综合九色综合97婷婷女人| 日韩女同互慰一区二区| 精品国产区一区| 久久精品视频免费| 国产精品美女www爽爽爽| 国产精品妹子av| 亚洲精品欧美激情| 亚洲一区二区三区自拍| 亚洲成人tv网| 久久国产乱子精品免费女| eeuss国产一区二区三区| 国产91精品免费| voyeur盗摄精品| 欧美在线三级电影| 69久久99精品久久久久婷婷| 在线综合亚洲欧美在线视频| 日韩一区二区三区三四区视频在线观看| 91精品在线免费| 2022国产精品视频| 国产欧美日本一区视频| 亚洲精品乱码久久久久久黑人| 亚洲第一成人在线| 久久精品二区亚洲w码| 国产精品一区一区| 色一情一乱一乱一91av| 欧美午夜电影网| 精品久久久久99| 自拍偷拍欧美精品| 视频一区国产视频| 丁香一区二区三区| 欧美中文字幕一区二区三区亚洲 | 在线观看网站黄不卡| 91麻豆精品久久久久蜜臀| 精品国内片67194| 日韩一区欧美小说| 午夜精品久久久久久久久久| 国产剧情av麻豆香蕉精品| 91黄视频在线| 精品国产三级a在线观看| 亚洲日本va在线观看| 免费观看日韩电影| 色综合色综合色综合 | 久久机这里只有精品| 成人动漫视频在线| 欧美一区二区精品久久911| 日本一区二区三区dvd视频在线| 亚洲国产精品久久不卡毛片| 国产乱色国产精品免费视频| 欧美日精品一区视频| 国产日韩三级在线| 青青草一区二区三区| 91麻豆国产福利在线观看| 欧美成人福利视频| 亚洲综合色视频| 成人午夜伦理影院| 日韩欧美一级二级三级| 亚洲一区二区3| 成人午夜激情在线| 精品剧情v国产在线观看在线| 一区二区三区日韩欧美精品| 国产精品羞羞答答xxdd| 欧美一区二区三区影视| 一区二区三区自拍| 成人夜色视频网站在线观看| 日韩精品一区二区三区swag| 午夜免费久久看| 91精品1区2区| 国产精品久久精品日日| 国产精品一色哟哟哟| 欧美一激情一区二区三区| 亚洲一级不卡视频| 成人av免费网站| 国产无一区二区| 国产美女久久久久| 精品日韩在线观看| 美女网站视频久久| 日韩一区二区三区三四区视频在线观看| 亚洲精品免费在线观看| 91视频com| 亚洲蜜桃精久久久久久久| 成人黄色免费短视频| 久久蜜桃av一区精品变态类天堂| 久久超碰97中文字幕| 日韩一区二区三区av| 青青草原综合久久大伊人精品优势| 欧美日韩精品一区二区三区蜜桃| 亚洲一卡二卡三卡四卡五卡| 欧美性高清videossexo| 亚洲一区二区在线视频| 精品视频999| 天天色天天爱天天射综合| 欧美日韩和欧美的一区二区| 天天影视涩香欲综合网| 欧美一区二区在线免费播放| 免费三级欧美电影| 精品久久国产97色综合| 国产一区二区三区综合| 国产日韩一级二级三级| 成人免费观看视频| 亚洲另类春色校园小说| 欧美影院精品一区| 天堂va蜜桃一区二区三区漫画版| 6080日韩午夜伦伦午夜伦| 热久久国产精品| 久久久久9999亚洲精品| 99综合电影在线视频| 一区二区三区日韩欧美精品| 在线成人免费视频| 毛片av一区二区| 欧美国产精品中文字幕| 91性感美女视频| 日韩和欧美一区二区三区| 日韩欧美三级在线| 成人av网站在线观看免费| 亚洲免费视频中文字幕| 91精品国产全国免费观看| 国产麻豆精品一区二区| 亚洲精品国产无天堂网2021| 91精品国产全国免费观看| 丁香天五香天堂综合| 亚洲综合区在线|