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;
}
Re: Basic help with Java class 80 80

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

Re: Basic help with Java class 80 80

S of string should be upper case ...

public Publication (String name, String type)

Re: Basic help with Java class 80 80

yup, upper case string to String
class String is found in: java.lang.String

Re: Basic help with Java class 80 80

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 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.