Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class prostopadłościan extends kwadrat {
- private int wysokosc;
- public prostopadłościan()
- {
- super();
- this.wysokosc=1;
- }
- public prostopadłościan(int c,int d)
- {
- super(d);
- this.wysokosc=c;
- }
- public int pole(int a)
- {
- return(a*pole()*2+4*zwrocBok()*wysokosc);
- }
- public int zwrocwyskosc()
- {
- return wysokosc;
- }
- }
- public class kwadrat {
- private int bok;
- public kwadrat()
- {
- bok=1;
- }
- public kwadrat(int b)
- {
- bok=b;
- }
- public kwadrat(kwadrat a)
- {
- this.bok=a.bok;
- }
- public int zwrocBok()
- {
- return bok;
- }
- public int pole()
- {
- return (bok*bok);
- }
- }
- import java.io.IOException;
- import java.nio.charset.StandardCharsets;
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import java.util.Collections;
- import java.util.List;
- public class Aplikacja {
- public static void main(String args[]) throws Exception
- {
- String data = "";
- data = new String(Files.readAllBytes(Paths.get("huju")));
- String w[];
- w=data.split("\n");
- String c[];
- int a=0;
- int b;
- for(int i=w.length-1;i>=0;i--) {
- System.out.println(w[i]);
- c=w[i].split(" ");
- if(c.length==2)
- {
- a=Integer.parseInt(c[1]);
- b=Integer.parseInt(c[0]);
- prostopadłościan d=new prostopadłościan(a,b);
- System.out.println("prostopadłościan ");
- System.out.println("pole=" + d.pole(b));
- }
- else
- {
- a=Integer.parseInt(c[0]);
- System.out.println(a);
- kwadrat d=new kwadrat(a);
- System.out.println("kwadrat");
- System.out.println("pole"+d.pole());
- System.out.println("bok"+d.zwrocBok());
- System.out.println("wysokosc"+d.z());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement