Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Esercizio L.2.8 + L.2.9 #8

Open
notedo opened this issue Mar 12, 2024 · 1 comment
Open

Esercizio L.2.8 + L.2.9 #8

notedo opened this issue Mar 12, 2024 · 1 comment

Comments

@notedo
Copy link
Member

notedo commented Mar 12, 2024

Screenshot 2024-03-12 alle 10 49 41 Screenshot 2024-03-12 alle 10 59 22
@notedo
Copy link
Member Author

notedo commented Mar 12, 2024

Da aggiungere la parte su stack e heap

public class Main {
    public static void main(String[] args) {
        Punto p01 = new Punto(1, 3, 8);
        Punto p02 = new Punto(4, 4, 7);

        Segmento s1 = new Segmento(p01, p02);
        System.out.println(s1);
    }
}

public class Segmento {
    private Punto p1, p2;
    public Segmento(Punto p1, Punto p2) {
        this.p1 = p1;
        this.p2 = p2;
    }

    @Override
    public String toString () {
        String stringa = p1 + " " + p2;
        return stringa;
    }
}

public class Punto {
    private int x,y,z;
    public Punto(int x, int y, int z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    @Override
    public String toString() {
        String string = "("+x+","+y+","+z+")";
        return string;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants