Created
September 21, 2022 06:59
-
-
Save ProfAndreaPollini/ba4e7d3f18c3f5799d597aa78cd5104d to your computer and use it in GitHub Desktop.
Lezione 21-09-2022
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package veicoli; | |
/** | |
* | |
* @author 15367519 | |
*/ | |
public class Auto extends Veicolo { | |
private final int nPorte; | |
private final String trazione; // ANT - POS - 4x4 | |
public Auto(int nPorte, String trazione, String telaio, | |
String targa, int cilindrata, int nRuote) { | |
super(telaio, targa, cilindrata, nRuote); | |
this.nPorte = nPorte; | |
this.trazione = trazione; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ereditarieta; | |
/** | |
* | |
* @author 15367519 | |
*/ | |
public class Driver { | |
public static void main(String[] args) { | |
var tri = new Triangolo(); | |
System.out.println(tri.area()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ereditarieta; | |
/** | |
* | |
* @author 15367519 | |
*/ | |
public class Poligono { | |
public float area() { | |
return 1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ereditarieta; | |
/** | |
* | |
* @author 15367519 | |
*/ | |
public class Triangolo extends Poligono { | |
@Override | |
public float area() { | |
return 2; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package veicoli; | |
/** | |
* | |
* @author 15367519 | |
*/ | |
public class Veicolo { | |
private final String telaio; | |
private final String targa; | |
private final int cilindrata; | |
private final int nRuote; | |
public Veicolo(String telaio, String targa, int cilindrata, int nRuote) { | |
this.telaio = telaio; | |
this.targa = targa; | |
this.cilindrata = cilindrata; | |
this.nRuote = nRuote; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment