Click here to Skip to main content
15,892,537 members

Comments by Freddie Francis (Top 13 by date)

Freddie Francis 8-Mar-23 12:18pm View    
ive moved the calls into their respected class but it still tells me undeclared, for example here;

public class Journal extends Publication
{
// The year and month when the journal was published
private int month;

/**
* Create a journal.
*
* @param title The title of the journal
* @param month The month when the journal was published
* @param year The year when the journal was published
*/
public Journal(String title, int month, int year)
{
super(title, year);
this.month = month;
database.addPublication(journal);
}
Freddie Francis 8-Mar-23 11:38am View    
it is done on blueJ
Freddie Francis 8-Mar-23 11:23am View    
ive tried doing this but i am getting error message, undeclared variables.
public class Database {
private ArrayList<publication> publicationList; // An array list collection of publications

/**
* Create a new database
*/
public Database() {
publicationList = new ArrayList<publication>();
}

/**
* Add a publication
*
* @param publication The publication to be added
*/
public void addPublication(Publication publication) {
if (publicationList.contains(publication)) {
System.out.println("This publication has already been added to the list: " + publication);
} else {
publicationList.add(publication);
database.addPublication(book);
database.addPublication(journal);
}
}
Freddie Francis 4-Dec-22 8:24am View    
Sorry i forgot to add my last method.

public Alien getNonHumanoids()
{
Iterator<alien> it = aliens.iterator();
while(it.hasNext()){
Alien alien = it.next();
if(alien.getHumanoid() == false){
it.remove();
nonHumanoids.add(alien);
}
}
}
Freddie Francis 2-Dec-22 11:14am View    
would this be correct

public void printNumbers()
{
System.out.print (numbers+"");
}