文章标题
来源:互联网 发布:ssm slf4j sql 编辑:程序博客网 时间:2024/06/07 01:16
封装
class Hua
{
private String name; //花的属性
private String color;
private String location;
public void setname(String name){ // 设置花对象的属性
this.name=name;
}
public void setcolor(String color){
this.color=color;
}
public void setlocation(String location){
this.location=location;
}
public String gatname(){ //访问器获得花属性
return name;
}
public String gatcolor(){
return color;
}
public String gatlocation(){
return location;
}
private void print(){
System.out.println(“这就是”+name);
}
public String tostring(){
String information=(“花名;”+name+”;”+” “+”花的颜色;”+color1+”;”+”“+”花的出产地;”+location);
print();
return information;
}
}
class Huatext
{
public static void main(String args){
flower f1=new flower(); //创建三个对象f1,f2,f3
flower f2=new flower();
flower f3=new flower();
f1.setname(“牡丹”);
f1.setcolor(“红色”);
f1.setlocation(“云南”);
f2.setname(“玫瑰”);
f2.setcolor(“黄色”);
f2.setlocation(“北京”);
f3.setname(“月季”);
f3.setcolor(“蓝色”);
f3.setlocation(“上海”);
//输出相应的信息
System.out.println(f1.tostring());
System.out.println(f2.tostring());
System.out.println(f3.tostring());
}
}
请各位大神们多多指教!!
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- hive 优化方法
- java学习基础
- 浅谈51单片机(c语言)中断以及定时器(计数器)的使用
- 关系型数据库与非关系型数据库的区别?
- 谷歌插件Image downloader开发之 content script
- 文章标题
- 安装vc2005运行库错误1935c处理
- SAP Table T149 - Valuation type/valuation class
- sql server使用教程(图文)
- Android拍照识别车牌号SDK
- PHP文件的基本操作
- mysql 5.6 bin包安装手记
- 使用Eclipse Color Thems插件导入xml的配色方案
- 2.2.1 实体声明