In JAVA please! The log class will allow to store multiple string messages but one at a...

60.1K

Verified Solution

Question

Programming

In JAVA please!

The log class will allow to store multiple string messages butone at a time (via record(..)), and also get back the wholesequence of messages (via read()).

assume and gurantee that each message is a single line oftext.

the fields can be of my/your choice

four different methods in this class include;

public Logger() . establishes a new and emptylog.

public Log duplicate() . this is not aconstructor, but creates a no-aliases copy of this log and returnsit. This becomes useful for when sharing the information withoutallowing modification.

public String[] read() . this will return anarray of strings where each item in the array is the next line ofthe recorded content.

public void record(String msg) . this willrecord the given message as the next line in the log file.

here you will assume there are no newline characters in themessage (the behavior is not defined if they are present; thismeans they must not be accounted for but if you want you can)

Answer & Explanation Solved by verified expert
4.5 Ratings (700 Votes)
Online URL for testing httpideonecomBikSrN import javautil class Log private ArrayList msgs public Log msgsnew ArrayList    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students