中国高校课件下载中心 》 教学资源 》 大学文库

西安电子科技大学:《网络计算》课程PPT教学课件(Android Programming)Lecture 2 Introduction to Java and Object Oriented Programming

文档信息
资源类别:文库
文档格式:PPTX
文档页数:53
文件大小:2.05MB
团购合买:点击进入团购
内容简介
• Classes & Objects Overview • Packages • Inheritance • Abstraction • Interfaces • Nested Classes Static nested & Inner classes Local & anonymous classes
刷新页面文档预览

Android Programming Lecture 2 Intro to Java Programming

Android Programming Lecture 2 Intro to Java Programming

Agenda Classes Objects Overview 。Packages ·Inheritance 。Abstraction ·Interfaces ·Nested Classes o Static nested Inner classes o Local anonymous classes 2

Agenda • Classes & Objects Overview • Packages • Inheritance • Abstraction • Interfaces • Nested Classes o Static nested & Inner classes o Local & anonymous classes 2

Objectives Identify the basic parts of a Java program Can identify a class and components of a class Read the codes in an app 3

Objectives • Identify the basic parts of a Java program • Can identify a class and components of a class • Read the codes in an app 3

Do{ if the baby is within 1-2 years old if the baby is happy today if the milk is still hot if... else... else else... else.…} while(the baby is not 6 years old) A computer would ask you to: What is a baby?Define it! 我们该如何教授计 What is a feeding bottle?Define it! 算机去理解我们? ·Vhat is milk?Define!

4 Do{ if the baby is within 1-2 years old if the baby is happy today if the milk is still hot if … else … else …. else … else…} while(the baby is not 6 years old) A computer would ask you to: • What is a baby? Define it! • What is a feeding bottle? Define it! • What is milk? Define! 我们该如何教授计 算机去理解我们?

Class and Object 5

Class and Object 5

What is an“Object'” An object is a thing,that we teach to the computer, so that the computer knows what the thing is Unlike people,a computer cannot see,feel and smell.It can only read codes.We have to define objects(or things)by describing the objects using (programming)languages. The way we describe a thing is composed of two parts o Attributes(variables,properties):what an object has o Methods:what an object can do

What is an “Object” • An object is a thing, that we teach to the computer, so that the computer knows what the thing is • Unlike people, a computer cannot see, feel and smell. It can only read codes. We have to define objects (or things) by describing the objects using (programming) languages. • The way we describe a thing is composed of two parts o Attributes (variables, properties): what an object has o Methods: what an object can do 6

Bicycle Music Music Player

7 Bicycle Music Music Player

Example:Bicycle Define the object for computers by specifying o The properties the object has o The functions the object provides ●Attributes: ·Method: o cadence o set cadence o gear o set the gear o speed o speed up o brake

Example: Bicycle 8 • Attributes: o cadence o gear o speed • Method: o set cadence o set the gear o speed up o brake • Define the object for computers by specifying o The properties the object has o The functions the object provides

package com.example.test; //A bicycle class Example taken from Oracle Docs... public class Bicycle public int cadence; public int gear; public int speed; public Bicycle(int startCadence,int startSpeed,int startGear) gear startGear; cadence startCadence; speed startSpeed; public void setCadence(int newvalue){ cadence newValue; } public void setGear(int newValue){ gear newValue; } public void applyBrake(int decrement){ speed -decrement; } Bicycle public void speedUp(int increment){ speed +increment; 9

9 Bicycle

package com.example.test; //A bicycle class Example taken from Oracle Docs... public class Bicycle Bicycle Class o can be thought of as a template,a prototype or a blueprint of an object o is the fundamental structure in object-oriented programming 10

10 Class o can be thought of as a template, a prototype or a blueprint of an object o is the fundamental structure in object-oriented programming Bicycle

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档