JAVA英文教学课件
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
why java?
• java provides for an object-oriented approach to programming, which is recommended current practice
• java is widespread • however, java is more complex than other
inheritance
• Person is the superclass from which Martha inherits all of her properties and some of her capabilities
back to the java code
• the body of the java class Martha contains:
• gain exposure to key programming concepts using examples
• program by modifying programs, rather than creating them from scratch
• hopefully, you can do more interesting things in this way
• objects have properties, recorded in variables • objects have capabilities, defined in methods
object example: Martha
• in VF, each character is an object • consider Martha:
• Mom, Dad, Sis, and Junior have certain things in common:
– properties, such as mood – capabilities, such as say and showAnimation
• in the code, the properties and capabilities common to all four are modeled as an object called Person
– a description of the properties of Martha – a constructor, which can be used by other
classes to create an instance of Martha – a description of the capabilities of Martha
programming languages that we could have chosen
goal for today’s lecture
• learn a little about java by examining some of the VF code
objects
• a java program is a collection of cooperating objects
• programming is a sophisticated activitiy, requiring lots of experience
• learning java takes significantly more time than learning html
our approach to java
• the body is enclosed by brackets { }
comments
• comments throughout the code are for the benefit of the reader (the programmer or others reading the code)
other properties later)
modeling Martha in java
• a model of an object is specified as a class • the comment at the start tells the reader that
this is the class Martha • the model starts with a class declaration:
• the capabilities such as Faint, etc. are composed of other, simpler capabilities:
– say – showAnimation – getMood – ...
Martha: properties
• mood • (we’ll come back Martha’s
– what capabilities does Martha have, . what can Martha do?
– what properties does Martha have?
Martha: capabilities
• Faint • Do a Cartwheel • ...
more capabilities
public class Martha extends Person • here public indicates that other classes can
create an object of this class • what does extends Person mean?
objects and superobjects
Java Programming
goal for next several lectures: provide an intro to object oriented programming in java
goal is try out programming, not to become experts