Write a constructor for the dictionary class

Assignment Help JAVA Programming
Reference no: EM132076103

Need help on JAVA homework.

The class below describes a Book. In the next questions, you will write a class called Dictionary.

For full credit, follow good principles of class design, encapsulation, and inheritance.

Recommend writing the class in your development environment to make sure it compiles and then copying the code into the appropriate question

public class Book {

private String title, author;

private int copyrightYear;

public Book(String title, String author, int copyrightYear) {

this.title = title;

this.author = author;

this.copyrightYear = copyrightYear;

}

public String getTitle() {

return title;

}

public String getAuthor() {

return author;

}

public int getCopyrightYear() {

return copyrightYear;

}

public void setAuthor(String author) {

this.author = author;

}

public void setTitle(String title) {

this.title = title;

}

public void setCopyrightYear(int copyrightYear) {

if(copyrightYear > 0) {

this.copyrightYear = copyrightYear;

}

}

@Override

public String toString() {

return title + " by " + author + " (" + copyrightYear + ")";

}

}

Question 1

Write the class header and the instance data variables for the Dictionary class.

A dictionary is a book that is further described by the number of words in the dictionary.

Question 2

Write a constructor for the Dictionary class. The constructor should initialize the instance data variables using parameters. The parameters should specify all information needed to describe a dictionary.

Question 3

Write accessor and mutator (getter and setter) methods. Include validity checking where appropriate.

Question 4

Write a toString method to return a text representation of the book. The text representation should include the title, author, year, and number of words, like this:

The Dictionary by Merriam-Webster (2015)

contains 171,500 words

Question 5

Write the equals method (including the method header) for the Book class (not the dictionary class). Two book objects are logically equivalent if they have the same title, author, and copyright year.

Question 6

Write code that would go inside of a main method. The code should create one book object and one dictionary object and invoke at least two methods on each object. Also include a statement to print a text representation of the book and the dictionary to the console.

Reference no: EM132076103

Questions Cloud

Find the number of units that should be sold : A) Find the number of units that should be sold in order to maximize the total profit. B) What is the maximum profit?
To practice more with collections and exceptions : These students do not have an ID, but they do have a phone number. Two students are the same if they have the same name and phone number.
Combined surface area of all six sides of the box : A box has a square base of side length x meters and height h meters. The volume of the box is V(h,x) and S(h,x) is the combined surface area of all six sides
Write a test program that creates two rectangle objects : Write a test program that creates two Rectangle objects-one with width 4 and height 40 and the other with width 3.5 and height 35.9.
Write a constructor for the dictionary class : Write a constructor for the Dictionary class. The constructor should initialize the instance data variables using parameters.
What are the values of a and b : A given curve in the family x2 + xy + ay2 = b has a tangent line at point (1, 3) with slope -5/14. What are the values of a and b?
Determine the position and velocity functions for the coin : A. Determine the position and velocity functions for the coin. B. Determine the average velocity of the coin on the interval [1, 3].
How many hours would it take for the object to travel 140 : How many hours would it take for the object to travel 140 miles?
Write a program to load random data into an array : Write a program to load random data into an array and time the sort operations using the various methods presented (and coded) in the textbook.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd