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

  Determine a character type without using the char methods

Determine a character type WITHOUT using the char methods - how to use if -else statements for this project.

  List two or three topics of java programming

Explain their importance and give an example of each. List two or three topics you need to work on to better understand their concepts

  Write a java method that perform a recursive descent parse

Determine whether the following grammar is an LL grammar by performing the pairwise disjointness test, showing the FIRST sets of each RHS of each nonterminal - Write a Java method that perform a recursive descent parse of the production.

  What is the smallest positive number representable

What is the smallest positive number (not including the +0) and largest negative number representable in 32-bit IEEE 754 single precision floating point?

  Write an application calccircumference

Write an application (CalcCircumference) that inputs from the user the radius of a circle as an integer and prints the circle's diameter, circumference and area using the floating-point value 3.14159 for ?.

  Write a java program the displays the state bird

Write a Java program the displays the State bird and flower. The program should prompt the user to enter a State and print both the State bird and flower.

  Employ jtable for an applet that displays the results

Employ JTable for an applet that displays the results of the above tasks. Hint: you may want to have single array accumulate rows from from the tasks.

  1 securityimplement security so that all users can view the

1. security.implement security so that all users can view the information about the projects but only authenticated

  Write a method called select_set

Write a method called select_set that takes in 1 parameter: followers (a 2D array of Tweeter users) and returns the user IDs of any number of users (as an array of integers) selected by your algorithm who will be selected to broadcast the advertis..

  Java coding if-else while loop

Code a while loop that keeps printing "You are a DEDICATED student!" as long as the user enters an attendance rate of 90% or greater. Assume the loop-control variable, attendance, is already declared along with input for the Scanner class. The w..

  Part-1prepare a program that teaches arithmetic to a young

part-1prepare a program that teaches arithmetic to a young child. the program tests subtraction and addition. in level

  Develop an ai for a game called fox

Develop an ai for a game called fox and geese it's part of my project for the class. Then check if there is any duck that can move to that spot.

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