505,972 views
40 votes
40 votes
Based on the data definition classes identified below, assume you wish to create a Dictionary class that inherits from the Book class. In addition to title and cost, the Dictionary class must also store the number of words present in the dictionary. Write the code that will create a constructor in the dictionary class that passes in and sets the dictionary's title, cost, and number of words.

User PatrickvL
by
3.2k points

1 Answer

24 votes
24 votes

Answer:

Step-by-step explanation:

The following code is written in Java and creates the constructor for the Dictionary class as requested. This class extends the Book class and assumes that the variables for the title and the cost are part of the Book class, so it simply calls and initializes them using the constructor.

class Dictionary extends Book {

int numberWords;

public void Dictionary(String title, int cost, int numberWords) {

this.title = title;

this.cost = cost;

this.numberWords = numberWords;

}

}

Based on the data definition classes identified below, assume you wish to create a-example-1
User Ruchika
by
2.8k points