Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7064923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:53:37+00:00 2026-05-28T04:53:37+00:00

I am working on a short java assignment that I have been set. The

  • 0

I am working on a short java assignment that I have been set.

The question is as follows:

Design and write classes to model different types of Publications in a Library. Consider carefully the different types of publications, e.g. Books and Magazines. Put all attributes and methods which are common to all types of Publications in a super-class, and then extend this super-class appropriately to create a set of sub-classes.

Make sure that you include appropriate constructor, getter, setter and customised methods in your classes. Use method overloading and overriding where appropriate.

Make maximum use of inheritance in your design and class code.

Implement the following Interface Class in your design and coding:

+ getPublisher() : String
+ getPublicationTitle() : String
+ getPrice : float
+ setPublication(publisherIn: String, titleIn:String, priceIn:float) : void

So I have answered it as best I can, please could anybody read it and check that I am on the right track and understand what I am meant to be doing, it seems fat to simple to be correct?
Oh and javadocs are not finished yet [=

public interface PublicationInterface
{
    /**
     * Returns the book publisher name (as a String) 
     */
    public String getPublisher();

    /**
     * Returns the book publication title (as a String)
     */
    public String getPublicationTitle();

    /**
     * Returns the book price (as a float)
     */
    public float getPrice();

    /**
     * Sets the book publication details.
     * 
     * @param publisherIn   The Book Publisher (as a String)
     * @param titleIn       The Book Title (as a String)
     * @param priceIn       The Book Price (as a float)
     */
    public void setPublication(String publisherIn, String publicationTitleIn, float priceIn);
}

abstract public class Publications implements PublicationInterface
{
   // Attributes
  protected String publisher;
  protected String publicationTitle;
  protected float price;

        public Publications(String publisherIn, String publicationTitleIn, float priceIn)
            {
                publisher = publisherIn;
                publicationTitle = publicationTitleIn;
                price = priceIn;
            }

        public String getPublisher()
            {
                return (publisher);
            }

        public String getPublicationTitle()
            {
                return (publicationTitle);
            }

        public float getPrice()
            {
                return (price);
            }

        public void setPublication(String publisherIn, String publicationTitleIn, float priceIn)
            {
                publisher = publisherIn;
                publicationTitle = publicationTitleIn;
                price = priceIn;
           }

}

public class Magazine extends Publications
{
    String editor;
    String date;

    public Magazine(String publisherIn , String publicationTitleIn, float priceIn, String editorIn, String dateIn)
        {
            super (publisherIn , publicationTitleIn, priceIn);

            editor = editorIn;
            date = dateIn;
        }

    public void setPublication(String publisherIn, String publicationTitleIn, float priceIn)
        {
            publisherIn = publisher;
            publicationTitleIn = publicationTitle;
            priceIn = price;
        }

    public String getEditor()
        {
            System.out.println("The editor of this magazine is " + editor);
            return (editor);
        }

    public String getDate()
        {
            System.out.println("The publication date of this magazine is " + date);
            return (date);
        }

    public String getPublisher()
        {
            System.out.println("The publisher of this magazine is " + publisher);
            return (publisher);
        }

    public String getPublicationTitle()
        {
            System.out.println("The publication title of this magazine is " + publicationTitle);
            return (publicationTitle);
        }

    public float getPrice()
        {
            System.out.println("The price of this magazine is £" + price);
            return (price);
        }

}

public class ReferenceMaterial extends Publications
{

    String genre;
    String subject;

    public ReferenceMaterial(String publisherIn , String publicationTitleIn, float priceIn,     String genreIn, String subjectIn)
        {
            super (publisherIn , publicationTitleIn, priceIn);            

            genre = genreIn;
            subject = subjectIn;
        }

    public String getGenre()
        {
            System.out.println("The genre of this material is " + genre);
            return (genre);
        }

    public String getSubject()
        {
            System.out.println("The subject of this material is " + subject);
            return (subject);
        }

    public String getPublisher()
        {
            System.out.println("The publisher of this material is " + publisher);
            return (publisher);
        }

    public String getPublicationTitle()
        {
            System.out.println("The publication title of this material is " + publicationTitle);
            return (publicationTitle);
        }

    public float getPrice()
        {
            System.out.println("The price of this material is £" + price);
            return (price);
        }
}


public class Book extends Publications
{
    int pageNumber;
    String author;

    public Book(String publisherIn , String publicationTitleIn, float priceIn, int pageNumberIn,     String authorIn)
        {
            super (publisherIn , publicationTitleIn, priceIn);

            pageNumber = pageNumberIn;
            author = authorIn;

        }

    public int getPageNumber()
        {
            System.out.println("The number of pages in this book are " + pageNumber);
            return (pageNumber);
        }

    public String getAuthor()
        {
            System.out.println("The author of this book is " + author);
            return (author);
        }

    public String getPublisher()
        {
            System.out.println("The publisher of this book is " + publisher);
            return (publisher);
        }

    public String getPublicationTitle()
        {
            System.out.println("The publication title of this book is " + publicationTitle);
            return (publicationTitle);
        }

    public float getPrice()
        {
            System.out.println("The price of this book is £" + price);
            return (price);
        }

}

public class TestLibrary
{

    public static void main()
      {     
        Magazine magazine1 = new Magazine ("SanYonic Publishing", "Ayup Magazine", 99, "Yeshumenku Suni", "12/09/2011");

        System.out.println();
        magazine1.getEditor();
        magazine1.getDate();
        magazine1.getPublisher();
        magazine1.getPublicationTitle();
        magazine1.getPrice();
        System.out.println();

        ReferenceMaterial referenceMaterial1 = new ReferenceMaterial ("Dorling kindesy", "killer Sharks In The Solent", 200, "Nature", "Sharks");

        referenceMaterial1.getGenre();
        referenceMaterial1.getSubject();
        referenceMaterial1.getPublisher();
        referenceMaterial1.getPublicationTitle();
        referenceMaterial1.getPrice();
        System.out.println();

        Book Book1 = new Book ("Hodder & Soughton", "One Day", 75, 1105, "David Nicholls");

        Book1.getPageNumber();
        Book1.getAuthor();
        Book1.getPublisher();
        Book1.getPublicationTitle();
        Book1.getPrice();
        System.out.println();        
      }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:53:37+00:00Added an answer on May 28, 2026 at 4:53 am

    This looks fine save that you don’t need the interface at all. I didn’t see it mentioned in the homework, and it’s certainly not necessary for subclassing.

    Interfaces are for common methods implemented by a set of classes that are otherwise not related (specifically not part of a class hierarchy).

    Since your classes all descend from the parent Publications class, there is not need for something like the PublicationsInterface in this case. The super class fills that role nicely.

    Publication p = new Book();
    p.setPublisher("Acme Books");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have been working on this project for a short while now. I
I have to write a multiplayer pacman game in Java for a university assignment
I have a lot of experience with java and c++ development, so classes and
I have been working with the example code from the ExecutorCompletionService and put together
I understand that this is a very broad question, but a short it depends
I only want a list of files that have been added (not ones that
I'm working on a small game written in Java (but the question is language-agnostic).
I'm trying to develop a Java web based application that can work flow different
I'm working on a programming assignment (in java) to solve a fifteen-puzzle sort of
I'm working on a homework assignment for Java, where a program is supposed to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.