Im getting the
systemB\Plumber.java:44: error: cannot find symbol
FilterOut.Connect(FilterWildPoints.pipe1);
^
symbol: variable pipe1
location: variable FilterWildPoints of type MiddleFilter
systemB\Plumber.java:56: error: cannot find symbol
FilterWildPoints.pipe1.start();
^
symbol: variable pipe1
location: variable FilterWildPoints of type MiddleFilter
2 errors
even thou, FilterWildPoints has a public member variable pipe1.
The big idea is, to have the Wild Points Filter split the stream into two other pipes and connect one of the pipes to the output.
Plumber.java:
package systemB;
public class Plumber
{
public static void main( String argv[])
{
SourceFilter FilterIn = new SourceFilter("./datasets/FlightData.dat");
MiddleFilter FilterTemperature = new MiddleFilterTemperature();
MiddleFilter FilterAltitude = new MiddleFilterAltitude();
MiddleFilter FilterWildPoints = new MiddleFilterWildPoints();
SinkFilter FilterOut = new SinkFilter("./OutputB.dat");
FilterOut.Connect(FilterWildPoints.pipe1);
FilterWildPoints.Connect(FilterAltitude);
FilterAltitude.Connect(FilterTemperature);
FilterTemperature.Connect(FilterIn);
FilterIn.start();
FilterTemperature.start();
FilterAltitude.start();
FilterWildPoints.pipe1.start();
FilterOut.start();
} // main
} // Plumber
MiddleFilterWildPoints.java:
package systemB;
import java.nio.ByteBuffer;
public class MiddleFilterWildPoints extends MiddleFilter
{
public MiddleFilter pipe1;
public MiddleFilter pipe2;
MiddleFilterWildPoints()
{
this.pipe1 = new MiddleFilter();
this.pipe2 = new MiddleFilter();
}
//...
} // MiddleFilter
I'm not very familier with java and need this for a assignment, but I can't find the Error.
You have declared FilterWildPoints
as MiddleFilter
, which does not have the pipe1
field.
Instead, declare FilterWildPoints
with a type of MiddleFilterWildPoints
:
MiddleFilterWildPoints FilterWildPoints = new MiddleFilterWildPoints();
The java compiler only looks at the declared type.
It would preferrable to follow standard java naming convention of variable names start with a lowercase letter. ie
MiddleFilterWildPoints filterWildPoints = new MiddleFilterWildPoints();
that way class names and variable names are more easily distinguished.
You must instantiate the object MiddleFilter. These instance will have their own attribute. In you try to use a static field from the class MiddleFilter named pipe1. (static are common through all instance of the same class). To solve this, create MiddleFilter middle = new MiddleFilter and then use middle.pipe.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.