Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

polymorphism, inheritance: get method is not getting anything

$
0
0
i have traced the problem to my vehicle class, me set method is setting as it should, but my get method is not getting anything. not sure where i have gone wrong. thanks for any help or hints.

/**
 * Abstract class Vehicle - write a description of the class here
 * 
 * @author Tara Sturgis
 * @version 12/8/2012
 */
public abstract class Vehicle
{
    // instance variables - replace the example below with your own
    protected double value;
    protected String maker;
    protected String owner;
    protected String color;

    public Vehicle ()
    {
        value = 0;
        maker = "Unknown maker";
        owner = "Unknown owner";
        color = "Unknown color";
    }
    public Vehicle(String m, double v, String c, String o)
    {
      // sets values for: maker, value, color, owner
    setMaker(m); 
    setValue(v);
    setColor(c);
    setOwner(o);  
    //System.out.println(" vehicle v " + v); correct
    }
    
    // sets instance maker to param maker  
    public void setMaker(String m)  
    {  
      maker = m;  
    }  
    
     // sets instance value to param value  
    public void setValue(double v)  
    {  
      value = v;  
      System.out.println(" set v " + value);  //correct
    }  
    
    // sets instance color to param color  
    public void setColor(String c)  
    {  
      color = c;  
    }  
    
    // sets instance owner to param owner  
    public void setOwner(String o)  
    {  
      owner = o;  
    }  
     public String getMaker()   
    {  
      return maker;  
    }  
    
    // returns value of vehicle  
    public double getValue()    
    { 
      System.out.println("get" + value);  //not getting anything
      return value;  
    } 
    
    // returns color of vehicle  
    public String getColor()  
    {  
      return color;  
    }  
    
    // returns owner of vehicle  
    public String getOwner()  
    {  
      return owner;  
    }  
    

  // vehicle tostring to be overwritten  
    public abstract String toString();
}




Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>