Hey everyone,
Alright, my project requires that I write a program to demonstrate my understanding of class inheritance. Problem is the teacher wants us to use Java, something I have never used and the teacher did not even give us a crash course in. Right now I am trying to compile this file (Publication.java) which contains the super class. I get errors saying the strings are unrecognizable symbols. This is probably pretty simple so could anyone tell me what is wrong?

public class Publication
    // Constructors
    public Publication () 
           {title = ""; medium = ""; copies = 0;}
    public Publication (string name, string type)    // Yields an error on this line
           {title = name; medium = type; copies = 0;} 

    // Methods 
    public int copiesprinted () {return copies;}
    public void incrementcopies () {copies++;}

    // Data
    private string title, medium;
    private int copies;
13 Years
Discussion Span
Last Post by paradox814

Actually Strings are classes in java. And java naming convention (it goes strict for atleast the JDK provided API) is to start classes with a CAPS.

In nutshell change string to String


something else that could be kind of helpful is to get on constructor to call the other:
for instance you could rewrite:

public Publication () 
{ title = ""; medium = ""; copies = 0; }


public Publication () 
	//this will call the constructor the format Publications (String s1, String s2)
	super ("","");

this isn't really a big deal but when your programs start getting huge its nice to have all the constructors in one spot instead of updating them all individually

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.