7.6实战练习第一题
Posted beens
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了7.6实战练习第一题相关的知识,希望对你有一定的参考价值。
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 }
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 }
以上是关于7.6实战练习第一题的主要内容,如果未能解决你的问题,请参考以下文章