Java error method is undefined for the type Echo -


i getting error on 11th line of code "e.results();" here driver class

import java.util.scanner; import java.io.*; public class linescrabbledriver {   public static void main(string args[]) throws ioexception {    string filename;    scanner namereader = new scanner(system.in);    system.out.println("enter file name");    filename = namereader.nextline();    echo e = new echo(filename);    e.readlines();    e.results();   } } 

this extended class of echo

import java.io.*; public class linescrabble extends echo{   double max = 0.0;   string bestword = "";   int linenumer = 0;   public linescrabble(string f) throws ioexception {     super(f);   } //scrabbles int[] scrabbles = {1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10}; //process given line public void processline(string s) {   s.tolowercase();   int score = 0;   for(int = 0; i<s.length(); i++){     char ch = s.charat(i);     if(character.isletter(ch)){       int pos = ch - 'a';       score += scrabbles[pos];       }     }   if(score > max){     max = score;     bestword = s;   } } //displays winner , score public void results() { system.out.println("winner: " + bestword); system.out.println("score: " + max/bestword.length()); } } 

here echo class

import java.util.scanner; import java.io.*;    public class echo{     string filename; // external file name     scanner scan; // scanner object reading external file      public echo(string f) throws ioexception     {      filename = f;      scan = new scanner(new filereader(filename));    }     public void readlines(){ // reads lines, hands each processline      while(scan.hasnext()){        processline(scan.nextline());      }      scan.close();   }    public void processline(string line){ // real processing work      system.out.println(line);    }  } 

i'm not quite sure why giving me undefined type error. i'm new java programming. please help!

because using original echo , not linescrabble, think wanted -

// echo e = new echo(filename); // linescrabble e = new linescrabble(filename); e.readlines(); e.results(); // <-- echo not have results() add there, or               // use linescrabble. 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -