Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Programming 3 classes required As you can imagine, a real conversation with a chatbot would be boring if it couldn't remember anything. For this

Java Programming

3 classes required

As you can imagine, a real conversation with a chatbot would be boring if it couldn't remember anything. For this reason, you'll create a Memory class. The memory class will contain variables for things a chatbot would want to remember. This will include it's name, height, favorite topic, etc. Your ChatBot class will contain a memory object that you will have to set up.

Objective

You will create the structure for a ChatBot. This includes a class to define and interact with the chatbot, and a class that will act as the chatbot's memory. You will create a chatbot object from main, and have it say the following things in sequence:

The chatbot will:

  1. say hello to the user.
  2. say it's name
  3. say what its favorite day of the week and hobby is.
  4. say what its quirk is
  5. ask the user about themselves.

There will be no human interaction for this assignment. You will hard-code all values.

Instructions

You will create three java classes for this project:

  1. Main.java (class name Main)
  2. ChatBot.java (class name ChatBot)
  3. Memory.java (class name Memory)

Using what you've learned about making classes, you will create the three java files mentioned above. (Note that any instance variable's you make need to have their accessibility set to private.)

The ChatBot class will contain the following:

  1. A Memory object that will be used to store each ChatBot instance's memories.
  2. A public constructor function called ChatBot().
    1. In this function, programmatically assign values to the chatbot's memory object. In other words, hard-code the values here. Use the memory object's "set" functions to give throw-away values to each Memory variable. I don't really care what name, height, weight favorite day, etc. you type in. (We'll do something more interesting in a future project.)
  3. A public function called interact(String userMessage)
    • For now, all this function will do is call each of the "reply" functions (listed below) one after the other. That is all.
  4. A private function called replyHello().
    • This function will print a simple hello message to the user.
  5. A private function called replyName()
    • This function will contain a System.out.print message that tells the user the chatbot's name.
  6. A private function called replyFavoriteThings()
    • This function will contain a System.out.print message that tells the user about the chatbot's favorite things (favorite hobby and day of the week).
  7. A private function called replyQuirk()
    • This function will contain a System.out.print message that tells the user the chatbot's quirk.
  8. A private function called replyAskAboutUser()
    • This function will contain a System.out.print message that asks the user to tell it about themselves.

The Memory class will contain the following:

  1. A String called name
  2. A String called favoriteHobby
  3. A String called favoriteDOTW (day of the week)
  4. A String called quirk
  5. A double called height (we'll assume this represents height in feet).
  6. A double called weight (we'll assume this represents weight in pounds)
  7. A public set and get function for each variable. (That's 12 functions in total.)
    • As all instance variables in Memory will be private, ChatBots will check their memory using their individual memory object's get and set functions.

In the Main class, create a Chatbot object in your main function. next, call that chatbot's interact function. That's all you'll do in main.

Goals

  • Experience with creating classes and objects.
  • Experience with using get and set functions

Sample Runs

Sample Program Run (note there is NO user input)

Hello there!

My name is Smithy!

I absolutely love Mondays and drawing things!

People say I'm very happy.

What about you? Can you tell me about yourself?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions