The example -- Puppy show the OOP
2017-11-01 09:49:36 0 举报
面向对象简单理解草图~~~~~~~~
作者其他创作
大纲/内容
myPuupy.puppyAge;
main method
myPuppy.getAge();
myPuppy.setAge(3);
public Puppy(String name)
get the int value and return
public void setAge(int age){puppyAge=age;}
set the int value 3 to the puppyAge
package com.ykmimi.testtest;/** * This is ukyo's first English notes ^-^y * This a example to show how to visit the * instance variable&use the member method * * @author ukyor * *///This is a class for dog -- Puppypublic class Puppy {\t//made a variable for the dog's age -- puppyAge\tint puppyAge;\t//this ''pulic Puppy()'' is a constructor\tpublic Puppy(String name) {\t\tSystem.out.println(\"Puppy's name is :\"+name);\t}\t//this method ↓ post a 'int age' to the puppyAge\tpublic void setAge( int age ) {\t\tpuppyAge = age;\t}\t//this method get the Age of the 'puppyAge'\tpublic int getAge() {\t\tSystem.out.println(\"Puppy's age is :\
pulic class Puppy
int puppyAge
Puppy myPuppy = new Puppy(\"tommy\");
public int getAge(){return puppyAge;}
0 条评论
下一页