Advertisement
EmhyrVanEmrias

Untitled

Apr 8th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. public class prostopadłościan extends kwadrat {
  2. private int wysokosc;
  3. public prostopadłościan()
  4. {
  5. super();
  6. this.wysokosc=1;
  7. }
  8. public prostopadłościan(int c,int d)
  9. {
  10. super(d);
  11. this.wysokosc=c;
  12. }
  13. public int pole(int a)
  14. {
  15. return(a*pole()*2+4*zwrocBok()*wysokosc);
  16.  
  17. }
  18. public int zwrocwyskosc()
  19. {
  20. return wysokosc;
  21. }
  22. }
  23. public class kwadrat {
  24. private int bok;
  25. public kwadrat()
  26. {
  27. bok=1;
  28. }
  29. public kwadrat(int b)
  30. {
  31. bok=b;
  32. }
  33. public kwadrat(kwadrat a)
  34. {
  35. this.bok=a.bok;
  36. }
  37. public int zwrocBok()
  38. {
  39. return bok;
  40. }
  41. public int pole()
  42. {
  43. return (bok*bok);
  44. }
  45.  
  46. }
  47. import java.io.IOException;
  48. import java.nio.charset.StandardCharsets;
  49. import java.nio.file.Files;
  50. import java.nio.file.Paths;
  51. import java.util.Collections;
  52. import java.util.List;
  53.  
  54. public class Aplikacja {
  55. public static void main(String args[]) throws Exception
  56. {
  57. String data = "";
  58. data = new String(Files.readAllBytes(Paths.get("huju")));
  59.  
  60.  
  61. String w[];
  62. w=data.split("\n");
  63. String c[];
  64. int a=0;
  65. int b;
  66. for(int i=w.length-1;i>=0;i--) {
  67. System.out.println(w[i]);
  68. c=w[i].split(" ");
  69. if(c.length==2)
  70. {
  71. a=Integer.parseInt(c[1]);
  72. b=Integer.parseInt(c[0]);
  73. prostopadłościan d=new prostopadłościan(a,b);
  74. System.out.println("prostopadłościan ");
  75. System.out.println("pole=" + d.pole(b));
  76.  
  77.  
  78.  
  79. }
  80. else
  81. {
  82.  
  83. a=Integer.parseInt(c[0]);
  84. System.out.println(a);
  85. kwadrat d=new kwadrat(a);
  86. System.out.println("kwadrat");
  87. System.out.println("pole"+d.pole());
  88. System.out.println("bok"+d.zwrocBok());
  89. System.out.println("wysokosc"+d.z());
  90.  
  91. }
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement