0

I am writing code for an algebra program to manipulate equations. I have the code for the Expression interface, and it compiled correctly. I also have the code for the Variable class, and it is failing to compile and raising the "error: cannot find symbol" for the Expression interface. They are in the same folder (in a "SymbolicExpressions" folder which is itself in an "Algebra" folder). I do not understand what is going wrong. Perhaps I have an environment variable set incorrectly. Any help you can provide would be much appreciated. Here is the code for the interface and the class:



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author zach
 */
public interface Expression extends Cloneable {
    abstract public Expression evaluate(Expression v, Expression e);

    abstract public Expression clone();

    abstract public Expression fullSimplify();

    abstract public Expression simpleSimplify();



}


import java.util.ArrayList;
import Algebra.SymbolicExpressions.Expression;
import java.lang.Character;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author zach
 */
public class Variable implements Expression, Comparable<Variable>, Cloneable {
    private char name;
    private ArrayList<Expression> subscripts;

    //Must implement infrastructure for subscripts, derivative superscripts. Potential implementation: earlier subscripts rank a higher order on the variable than later superscripts. In other words earlier subscripts decide variable's implementation of comparable before later subscripts. Superscript derivatives give higher priority based on the highest priority derivative's lowest order. Hopefully that makes sense the next time this comment is read
    public Variable(char myName, ArrayList<Expression> subscriptInputs) {
        name = myName;
        for (Expression e: subscriptInputs) {
            subscripts.add(e);
        }
    }



    public Expression evaluate(Expression v, Expression e) {
        if (this.compareTo(v)) {
            return e;
        }
        return this;
    }


    @Override
    public int hashCode() {
        return Character.valueOf(name).hashCode();
    }


    public Expression fullSimplify() {
        return this.clone(); //To change body of generated methods, choose Tools | Templates.
    }

    public Expression simpleSimplify() {
        return this.clone(); //To change body of generated methods, choose Tools | Templates.
    }


    public int compareTo(Variable toCompare) {
        return this.hashCode() - toCompare.hashCode();
    }


    public Expression clone() {
        return new Variable(this.name, this.subscripts);
    }

}
Zach O
  • 3
  • 3
  • Maybe a wrong guess but did you check your packages? The ones you placed these java source files in? – Anton Kahwaji Nov 25 '19 at 01:35
  • The Variable is in "package Algebra.SymbolicExpressions;" and the Expression is in "package Algebra.SymbolicExpressions;" and when I ls in my command line both show up in the SymbolicExpressions folder – Zach O Nov 25 '19 at 01:36
  • I believe [this](https://stackoverflow.com/a/13408363/6877477) might help you – Anton Kahwaji Nov 25 '19 at 01:46
  • Okay, thank you Anton. The cp flag did the trick – Zach O Nov 25 '19 at 02:21
  • How should I go about compiling my classes when they are in separate subdirectories? I have a Numbers package, a SymbolicExpressions package, a Relations package, and a Test package in the Algebra package. Should I create a jar? – Zach O Nov 25 '19 at 02:23
  • You can try [this](https://stackoverflow.com/a/8769536/6877477) combined with the previous link. For example for windows I tried `dir /s /B *.java > sources.txt` and then `javac -d out -sourcepath src @sources.txt`. I also had to manually edit the sources.txt to replace single \ with double \\ in the paths and add "" (quotes) around the paths. But at this point why not try using an IDE? Like Intellij or Eclipse. Or even VS Code I believe can do the work just fine (but I'm not sure). – Anton Kahwaji Nov 26 '19 at 00:18
  • Hi Anton. Thank you for your help. I believe that I figured out what I was doing wrong. I think I was using the backwards order for my package names. I have not had the opportunity to check that because I since changed the codebase to an incomplete state that cannot at the moment be compiled. But I think that was what I was doing wrong. I gave up using an IDE after Eclipse failed on me when I tried to use unusual characters. For some reason I messed around with some of the settings in an inappropriate way and it crashed the editor permanently for me. So I am doing it the "old fashioned way" – Zach O Feb 13 '20 at 14:05

0 Answers0