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;
}

Hi,
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

S of string should be upper case ...

public Publication (String name, String type)

yup, upper case string to String
class String is found in: java.lang.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; }

as

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.