Warning
This page is located in archive.

12. cvičení

package trida;
import java.util.Scanner;
 
/**
 *
 * @author havlicr
 */
class metody{
public static int NactiCislo(String s){
Scanner klv = new Scanner(System.in);
    System.out.print(s);
    return klv.nextInt();
}    
}
 
public class Trida {
 
 
    public static void main(String[] args) {
        int a,b,os,od;
        Obdelnik o1 = new Obdelnik();
        a = metody.NactiCislo("Zadej prvni cislo: ");
        b = metody.NactiCislo("Zadej druhe cislo: ");
        Obdelnik o2 = new Obdelnik(a);
        Obdelnik o3 = new Obdelnik(a,b);
        os = o1.Obsah();
        od = o1.Obvod();
        System.out.println("Obdelnik 1 :"+od+" "+os);
        os = o2.Obsah();
        od = o2.Obvod();
        System.out.println("Obdelnik 2 :"+od+" "+os);
        os = o3.Obsah();
        od = o3.Obvod();
        System.out.println("Obdelnik 3 :"+od+" "+os);
 
    }
}
 
class Obdelnik{
    int a;
    int b;
 
public Obdelnik(){
    this.a = 0;
    this.b = 0;
}
public Obdelnik(int a){
    this.a = a;
    this.b = 0;
}
public Obdelnik(int a, int b){
    this.a = a;
    this.b = b;
}
public int Obsah(){
return this.a*this.b;
}
public int Obvod(){
return 2*(this.a+this.b);
}
 
 
}

courses/a0b36pri/teacher/havlicr/cv12.txt · Last modified: 2015/01/16 21:04 (external edit)