java Overview In this assignment, you will create a class Publisher (publisher) and two test classes that create a number of different objects / instances of Publisher. The purpose of the task is to get acquainted with the concepts of object, class, method, constructor and overlay. Task You must write a class that represents a publisher (which will then be used in the next assignment). You rename the class to Publisher and are consequently saved in a source file called Publisher.java. The class must contain information about the publisher's name and telephone number. The operations we should be able to perform on objects of the class are to set and retrieve names and set and retrieve telephone numbers. It should also be possible to print all information about a publisher on the screen. In addition to this, the class must also contain a static instance variable for counting the number of created publishers, as well as a method that returns the number of created publishers. You should also write two different classes to try to create objects by Publisher and to use the methods it has. In one class (advantageously called PublisherTest1) you must create at least three different objects of Publisher and with the help of these objects then demonstrate all methods. This is done e.g. by combining method calls and screen prints. Put name and phone number directly in the code, i.e. "Hard coded". In the second test class (PublisherTest2) at least one object of Publisher must be created. Instead of "hard-coding" data, your program should ask the user for the publisher's name and phone number. After that, it is enough to print out all the information about the publisher. Select whether you want to use dialog boxes or if you use the class or Scanner. The class diagram below (UML) gives you an idea of ​​what the classes are supposed to look like (what instance variables and methods there should be). The set and get methods in the Publisher class need no further explanation. In addition to these methods, there must be (at least) two different constructors. A constructor without parameters and a Constructor that sets values ​​for all instance variables in the class. The print method should "neatly and neatly" print all information about the publisher on the screen. The toString method should return a string representation of the publisher. Decide for yourself what information may be appropriate to return. Requirement In order for the assignment to be considered approved, in addition to the above-mentioned details, the following is required: • No public instance variables may be in any class, only methods and constructors may be public. • All screen prints should be well-structured and easy to understand. Comment on the source code and describe what is happening. Classes and methods must be commented on with documentation comments as follows: • Classes / ** * Description and purpose of the class * @author (Name of the creator of the class) * @version (use 1.0 when submitting) * / • Methods / ** * Describe what the method does, and (if applicable) * @param (describe any parameter 1 that is submitted to the method) * @param (describe any parameter 2 that is submitted to the method) * @return (describe any return value) * / These comments must be placed immediately above the respective class / method. Also comment if necessary inside the methods to describe what is happening

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

java

Overview
In this assignment, you will create a class Publisher (publisher) and two test classes that create a number of different objects / instances of Publisher. The purpose of the task is to get acquainted with the concepts of object, class, method, constructor and overlay.
Task
You must write a class that represents a publisher (which will then be used in the next assignment). You rename the class to Publisher and are consequently saved in a source file called Publisher.java. The class must contain information about the publisher's name and telephone number.
The operations we should be able to perform on objects of the class are to set and retrieve names and set and retrieve telephone numbers. It should also be possible to print all information about a publisher on the screen. In addition to this, the class must also contain a static instance variable for counting the number of created publishers, as well as a method that returns the number of created publishers.
You should also write two different classes to try to create objects by Publisher and to use the methods it has. In one class (advantageously called PublisherTest1) you must create at least three different objects of Publisher and with the help of these objects then demonstrate all methods. This is done e.g. by combining method calls and screen prints. Put name and phone number directly in the code, i.e. "Hard coded".
In the second test class (PublisherTest2) at least one object of Publisher must be created. Instead of "hard-coding" data, your program should ask the user for the publisher's name and phone number. After that, it is enough to print out all the information about the publisher. Select whether you want to use dialog boxes or if you use the class or Scanner.
The class diagram below (UML) gives you an idea of ​​what the classes are supposed to look like (what instance variables and methods there should be).

The set and get methods in the Publisher class need no further explanation. In addition to these methods, there must be (at least) two different constructors. A constructor without parameters and a Constructor that sets values ​​for all instance variables in the class.
The print method should "neatly and neatly" print all information about the publisher on the screen. The toString method should return a string representation of the publisher.
Decide for yourself what information may be appropriate to return.

Requirement
In order for the assignment to be considered approved, in addition to the above-mentioned details, the following is required:
• No public instance variables may be in any class, only methods and constructors may be public.
• All screen prints should be well-structured and easy to understand.
Comment on the source code and describe what is happening.

Classes and methods must be commented on with documentation comments as follows:
• Classes
/ **
* Description and purpose of the class
* @author (Name of the creator of the class)
* @version (use 1.0 when submitting)
* /
• Methods
/ **
* Describe what the method does, and (if applicable)
* @param (describe any parameter 1 that is submitted to the method)
* @param (describe any parameter 2 that is submitted to the method)
* @return (describe any return value)
* /
These comments must be placed immediately above the respective class / method.
Also comment if necessary inside the methods to describe what is happening.

Publisher
PublisherTest1
- name : String
- phone : String
- nrOfPublishers : int
use
1..1
3..
*
+ main(args : String[ ])
+ Publisher()
+ Publisher(name : String, phone : String)
+ setName(name : String)
+ setPhone(phone : String)
+ getName() : String
+ getPhone() : String
+ print()
+ toString() : String
+ getnrOfPublishers() : int
PublisherTest2
use
1..1
1..*
+ main(args : String[ ])
Transcribed Image Text:Publisher PublisherTest1 - name : String - phone : String - nrOfPublishers : int use 1..1 3.. * + main(args : String[ ]) + Publisher() + Publisher(name : String, phone : String) + setName(name : String) + setPhone(phone : String) + getName() : String + getPhone() : String + print() + toString() : String + getnrOfPublishers() : int PublisherTest2 use 1..1 1..* + main(args : String[ ])
Expert Solution
steps

Step by step

Solved in 3 steps with 7 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT