Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cvicenie2.uloha2;
- public class Obdlznik {
- float stranaA=1;
- float stranaB=1;
- private static int pocet=0;
- /**
- * @author kovko
- * @param1 float Strana a
- * @param2 float Strana b
- */
- public Obdlznik(float stranaA, float stranaB){
- this.stranaA=stranaA;
- this.stranaB=stranaB;
- pocet++;
- }
- //alternativny konstruktor
- public Obdlznik(){
- pocet++;
- }
- /**
- * @author kovko
- * @param1 float Strana a
- * @param2 float Strana b
- * @return float obvod obdlznika
- */
- public float obvod(){
- return 2*(this.stranaA+this.stranaB);
- }
- /**
- * @author kovko
- * @param1 float Strana a
- * @param2 float Strana b
- * @return float obsah obdlznika
- */
- public float obsah(){
- return this.stranaA*this.stranaB;
- }
- /**
- * @author kovko
- * @param1 float Strana a
- * @param2 float Strana b
- * @return float dlzku uhlopriecky obldznika
- */
- public float uhlopriecka(){
- return (float)Math.sqrt(Math.pow(this.stranaA, 2)+Math.pow(this.stranaB, 2));
- }
- /**
- * @author kovko
- * @return pocet instancii triedy Obldznik
- */
- public static int pocet(){
- return pocet;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement