Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Rownanie {
- void wstawDane(){}
- void wyswietlDane(){}
- void wyswietlRozwiazanie(){}
- }
- public class LiniaProsta extends Rownanie{
- int x;
- int a;
- int b;
- LiniaProsta(){
- }
- void wstawDane(int x, int a, int b){
- this.x = x;
- this.a = a;
- this.b = b;
- }
- void wyswietlDane(){
- System.out.println("a = " + a + ", b = " + b);
- System.out.println("x = " + x);
- }
- void wyswietlRozwiazanie(){
- System.out.println("y = " + (a*x + b));
- }
- }
- public class Parabola extends Rownanie {
- int x;
- int a;
- int b;
- int c;
- Parabola(){
- }
- void wstawDane(int x, int a, int b, int c){
- this.x = x;
- this.a = a;
- this.b = b;
- this.c = c;
- }
- void wyswietlDane(){
- System.out.println("a = " + a + ", b = " + b + ", c = " + c);
- System.out.println("x = " + x);
- }
- void wyswietlRozwiazanie(){
- System.out.println("y = " + (a*x*x + b*x + c));
- }
- }
- public class Main {
- public static void main(String[] args) {
- Parabola par = new Parabola();
- LiniaProsta linia = new LiniaProsta();
- par.wstawDane(2, 1, 2, 3);
- par.wyswietlDane();
- par.wyswietlRozwiazanie();
- System.out.println();
- linia.wstawDane(2, 1, 2);
- linia.wyswietlDane();
- linia.wyswietlRozwiazanie();
- }
- }
Add Comment
Please, Sign In to add comment