Guest User

Untitled

a guest
Jul 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. public abstract class Rownanie {
  2.  
  3. void wstawDane(){}
  4.  
  5. void wyswietlDane(){}
  6.  
  7. void wyswietlRozwiazanie(){}
  8. }
  9.  
  10. public class LiniaProsta extends Rownanie{
  11.  
  12. int x;
  13. int a;
  14. int b;
  15.  
  16. LiniaProsta(){
  17. }
  18. void wstawDane(int x, int a, int b){
  19. this.x = x;
  20. this.a = a;
  21. this.b = b;
  22. }
  23.  
  24. void wyswietlDane(){
  25. System.out.println("a = " + a + ", b = " + b);
  26. System.out.println("x = " + x);
  27. }
  28.  
  29. void wyswietlRozwiazanie(){
  30. System.out.println("y = " + (a*x + b));
  31. }
  32.  
  33. }
  34.  
  35.  
  36. public class Parabola extends Rownanie {
  37.  
  38. int x;
  39. int a;
  40. int b;
  41. int c;
  42.  
  43. Parabola(){
  44. }
  45. void wstawDane(int x, int a, int b, int c){
  46. this.x = x;
  47. this.a = a;
  48. this.b = b;
  49. this.c = c;
  50. }
  51.  
  52. void wyswietlDane(){
  53. System.out.println("a = " + a + ", b = " + b + ", c = " + c);
  54. System.out.println("x = " + x);
  55. }
  56.  
  57. void wyswietlRozwiazanie(){
  58. System.out.println("y = " + (a*x*x + b*x + c));
  59. }
  60.  
  61. }
  62.  
  63. public class Main {
  64.  
  65. public static void main(String[] args) {
  66.  
  67. Parabola par = new Parabola();
  68.  
  69. LiniaProsta linia = new LiniaProsta();
  70.  
  71. par.wstawDane(2, 1, 2, 3);
  72. par.wyswietlDane();
  73. par.wyswietlRozwiazanie();
  74.  
  75. System.out.println();
  76.  
  77. linia.wstawDane(2, 1, 2);
  78. linia.wyswietlDane();
  79. linia.wyswietlRozwiazanie();
  80. }
  81.  
  82. }
Add Comment
Please, Sign In to add comment