David Schwartz

Greenhorn
+ Follow
since May 28, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by David Schwartz

yes it is from Deitel and Deitel book (5th edition)
13 years ago

Christophe Verré wrote:You usually do it to call methods that a class has, but that its interface/super class has not. Methods getBaseSalary and setBaseSalary are called. Are these methods also in Employee ?



yes, i believe they are in the Employee class
13 years ago
wanted to ask where i can find simple instructions on how to run a simple inheritance (see code below) in Eclipse?


thank you


=============

=============
how are you?
wanted to ask you why this code is using Downcasting (1st code fragment line 36-37)? i.e.
in the line below

should not the compiler dynamically 'find out' that it is dealing with a subclass of CurrentEmployee
and use the appropriate functions in that sub-class (BasePlusCommissionEmployee)?
thank you
=================

==============
BasePlusCommissionEmployee
==============

============
CommissionEmployee
=============

13 years ago
yes, thank you very much!
it compiled and created the appropriate class file.
I was indeed doing it under windows which means i had to use ';' throughout and not mix it up with Unix Shell's ':'
15 years ago
i am getting 3 erros by the compiler:
1)package com.example.model does not exist...
2)cannot find symbol class ^BeerExpert... BeerExpert beer = new BeerExpert();
3)cannot find symbol class BeerExpert... BeerExpert beer = new ^BeerExpert();
15 years ago
yes, i understand that there was a dependency.
that is why i 1st had to compile (successfully) BeerExpert.java
The only problem is BeerSelect.java does not compile
15 years ago
P.S. Sorry here is the command line to compile BeerSelect.java

c:\study\beerV1>javac -classpath c:\tomcat\common\lib\servlet-api.jar;classes:. -d classes c:\study\beerV1\src\com\example\web\BeerSelect.java

Here is the command line which I successfully used to compile BeerExpert.java

c:\study\beerV1>javac -classpath c:\tomcat\common\lib\servlet-api.jar;classes:. -d classes c:\study\beerV1\src\com\example\model\BeerExpert.java
15 years ago
I was wondering if anyone could help me out. I was trying to compile BeerSelect.java after following all steps on page 84 of HFSJ book.
I have exactly the same sub-directory structure and etc.
and i am getting 3 erros by the compiler:
1)package com.example.model does not exist...
2)cannot find symbol class ^BeerExpert... BeerExpert beer = new BeerExpert();
3)cannot find symbol class BeerExpert... BeerExpert beer = new ^BeerExpert();
Below I have included all the JAVA code.
thank you,


David

Here is the code for BeerSelect.java
package com.example.web;

//VERY IMPORTANT
import com.example.model.*;
//import com.example.web.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;



public class BeerSelect extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// insterted the line below
PrintWriter out = response.getWriter();
String c = request.getParameter("color");

System.out.println("<br>Gor beer color " + c);
BeerExpert beer = new BeerExpert();
List result = beer.getBrands(c);

response.setContentType("text/html");
//PrintWriter out = response.getWriter();
out.println("Beer Selection Advice<br>");

Iterator it = result.iterator();
while(it.hasNext())
{
out.print("<br>try: " + it.next());
}
}
}
Here is the code for BeerExpert.java
package com.example.model;
//Inserted this line
//import com.example.web.*;
import java.util.*;



public class BeerExpert{
public List getBrands(String color) {
List brands = new ArrayList();
if (color.equals("amber"))
{
brands.add("Jack Amber");
brands.add("Red Moose");
}
else
{
brands.add("Jail Pale Ale");
brands.add("Gout Stout");
}
return (brands);
}

}
15 years ago