Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CalculatingMachine {
- public String string;
- public CalculatingMachine(String string){
- this.string = string;
- }
- public String calculate(double x, double y){
- double suma = x + y;
- return string+": "+x+"+"+y+"="+suma;
- }
- public static void printRes(CalculatingMachine[] a, double x, double y){
- for(int i=0; i<a.length; i++){
- System.out.println(a[i].calculate(x,y));
- }
- }
- }
- //////////////////////////////////////////////////////////////////////////
- public class Computer
- extends Calculator {
- public Computer(String string){
- super(string);
- }
- public String calculate(double x, double y){
- double iloczyn = x*y, iloraz = x/y;
- return super.calculate(x,y)+"; "+x+"*"+y+"="+iloczyn+"; "+x+"/"+y+"="+iloraz;
- }
- }
- //////////////////////////////////////////////////////////////////////////
- public class Calculator
- extends CalculatingMachine {
- public Calculator(String string){
- super(string);
- }
- public String calculate(double x, double y){
- double roznica = x-y ;
- return super.calculate(x,y)+"; "+x+"-"+y+"="+roznica;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement