image.png

    1. package com.atguigu.exercise;
    2. public class TriAngleTest {
    3. public static void main(String[] args) {
    4. TriAngle t1 = new TriAngle();
    5. t1.steBase(2.1);
    6. t1.steHeight(5.0);
    7. System.out.println(t1.getBase()+" , "+ t1.steHeight());
    8. }
    9. }
    10. package com.atguigu.exercise;
    11. public class TriAngle {
    12. private double base;//底边长
    13. private double height;//高
    14. //构造器
    15. public TriAngle(){
    16. }
    17. public TriAngle(double b,double h){
    18. base = b;
    19. height = h;
    20. }
    21. //方法
    22. public void steBase(double b){
    23. base = b;
    24. }
    25. public double getBase(){
    26. return base;
    27. }
    28. public void steHeight(double h){
    29. height = h;
    30. }
    31. public double steHeight(){
    32. return height;
    33. }
    34. }