码迷,mamicode.com
首页 > 其他好文 > 详细

7.6实战练习第一题

时间:2016-03-06 17:31:23      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:

Yinliao类代码:

技术分享
 1 package org.hanqi.pn0120;
 2 
 3 public class Yinliao {
 4 
 5     private String mingcheng;
 6     private double jiage;
 7     public String getMingcheng() {
 8         return mingcheng;
 9     }
10     public void setMingcheng(String mingcheng) {
11         this.mingcheng = mingcheng;
12     }
13     public double getJiage() {
14         return jiage;
15     }
16     public void setJiage(double jiage) {
17         this.jiage = jiage;
18     }
19     public Yinliao(String mingcheng, double jiage) {
20         super();
21         this.mingcheng = mingcheng;
22         this.jiage = jiage;
23     }
24     public void drink()
25     {
26         System.out.println("我要喝"+this.mingcheng);
27         System.out.println(this.mingcheng+"的价格是:"+this.jiage);
28     }
29 }
View Code

Test类中的代码:

技术分享
 1 package org.hanqi.pn0120;
 2 
 3 public class Testdrink {
 4 
 5     public static void main(String[] args) {
 6         // TODO Auto-generated method stub
 7         Yinliao mydrink=new Yinliao("橙汁",3);
 8         mydrink.drink();
 9     }
10 
11 }
View Code

技术分享

 

7.6实战练习第一题

标签:

原文地址:http://www.cnblogs.com/beens/p/5247808.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!