Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Control.Control4;
- import java.util.*;
- import java.io.*;
- class Function{
- double eval(double x){
- if (s == "square"){
- double ev = a*(x*x)+b*x+c;
- return ev;
- }
- else {
- double ev = Math.log(x)/Math.log(a);
- return ev;
- }
- }
- String show(){
- if (s == "square"){
- String l = "(" + a + ")*x^2+(" + b + ")*x+(" + c + ")";
- return l;
- }
- else {
- String l = "log_" + a + "_(x)";
- return l;
- }
- }
- private int a;
- private int b;
- private int c;
- private String s;
- public Function(int a, int b, int c, String s){
- this.a = a;
- this.b = b;
- this.c = c;
- this.s = s;
- }
- }
- class Square extends Function{
- public Square(int a, int b, int c){
- super(a, b, c, "square");
- }
- }
- class Log extends Function{
- public Log(int a){
- super(a, 0, 0, "log");
- }
- }
- public class Ex_1 {
- public static void main(String[] args){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement