其他分享
首页 > 其他分享> > 2019.12.19 面向对象练习题

2019.12.19 面向对象练习题

作者:互联网

package com.DuiXiang;
public class TransferTest3 {
public static void main(String args[]) {
TransferTest3 test = new TransferTest3();
test.first();

}
public void first() {
int i = 5;
Value v = new Value();
v.i = 25;
second(v, i);
System.out.println(v.i);
}
public void second(Value v, int i) {
i = 0;
v.i = 20;
Value val = new Value();
v = val;
System.out.println(v.i + " " + i);
}
}

class Value {
int i = 15;
}

*************************************************************************************************************

/**
* TriAngleTest.java
* com.DuiXiang
*
* Function: TODO
*
* ver date author
* ──────────────────────────────────
* 2019年12月18日 17671
*
* Copyright (c) 2019, TNT All Rights Reserved.
*/

package com.DuiXiang;


/**
* ClassName:TriAngleTest

* Function: TODO ADD FUNCTION
* Reason: TODO ADD REASON
*
* @author 17671
* @version
* @since Ver 1.1
* @Date 2019年12月18日 下午3:20:26
*
* @see
*/
class TriAngle{
private double base;
private double height;
public TriAngle(){

}
public double getBase() {
return base;
}
public void setBase(double base) {
this.base = base;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public void area() {
System.out.println("三角形的面积为:"+base*height);
}
}
public class TriAngleTest {
public static void main(String[] args) {
TriAngle triAngle = new TriAngle();
triAngle.setBase(2.8);
triAngle.setHeight(3.9);
triAngle.area();

}
}

标签:练习题,19,double,void,Value,height,base,2019.12,public
来源: https://www.cnblogs.com/aojie/p/12069558.html