简体   繁体   中英

get class(Something something) into final

I don't quite know how to explain this but I have Triangle.class and Main.class and I am trying to get an edge from the public Triangle:

Triangle:

public class Triangle {

    public Triangle(Edge ab, Edge bc, Edge ca) {

    }
    private int perimeter;
    private boolean isATriangle;
    private Edge edge1;
    private Edge edge2;
    private Edge edge3;

    public boolean isTriangle(Triangle triangle){

        if(edge1.getLength() + edge2.getLength() > edge3.getLength() &&
           edge2.getLength()+edge3.getLength() > edge1.getLength() &&
           edge3.getLength()+edge1.getLength() > edge2.getLength()){
            return isATriangle = true;
        }
        else{
            return isATriangle = false;
            }
    }

    public int setPerimeter(int perimeter1) {
        return this.perimeter = perimeter1;     
    }

    public int getPerimeter() {
        return Integer.valueOf(perimeter);
    }
}

EDIT: Let me make myself clear because I know I wasnt clear. I want to create a "public boolean isTriangle(Triangle triangle){" and to get edge1 edge2 and edge3 that makes Triangle triangle. how can I do that?

Your Edge fields are marked as private like this:

private Edge edge1;

You can make them public or define get functions on the Triangle class

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM