面向对象
Posted 刘某人丶
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了面向对象相关的知识,希望对你有一定的参考价值。
package com.hanqi; public class Pingguo { private String Zhonglei;// 种类 public String getZhonglei() { return Zhonglei; } private String YanSe;// 颜色 public void setYanSe(String yanSe) { YanSe = yanSe; } public String getYanSe() { return YanSe; } private String DaXiao;// 大小 public String getDaXiao() { return DaXiao; } public void setDaXiao(String daXiao) { DaXiao = daXiao; } private String WeiDao;// 味道 public String getWeiDao() { return WeiDao; } public void setWeiDao(String weiDao) { WeiDao = weiDao; } int ChiYiGePingGuo; public double getCygPG(int yige) { return ChiYiGePingGuo = ( yige *=10); } public Pingguo() { System.out.println("好吃的苹果"); } }
package com.hanqi; public class Test { public static void main(String[] args) { Pingguo hongFuShi = new Pingguo(); hongFuShi.getZhonglei(); hongFuShi.setYanSe("红色"); hongFuShi.setDaXiao("大苹果"); hongFuShi.setWeiDao("甜中带酸"); hongFuShi.ChiYiGePingGuo=10; System.out.print("红富士"); System.out.println(hongFuShi.getYanSe()+hongFuShi.getDaXiao()+hongFuShi.getWeiDao()); System.out.println("吃10个苹果"+hongFuShi.getCygPG(10)); } }
以上是关于面向对象的主要内容,如果未能解决你的问题,请参考以下文章