Question: Create a Java interface file for an interface called MessageSender. And one more Java interface called Mammoth. ( a ) With the correct project selected,

Create a Java interface file for an interface called MessageSender. And one more Java interface called Mammoth.
(a) With the correct project selected, in the File menu select New File...
(b) Under Categories: make sure that Java is selected.
(c) Under File Types: make sure that Java Interface is selected.
(d) Click Next.
(e) For Class Name: type MessageSender.
(f) For Package: select or type csci2011.lab4.
(g) Click Finish.
(h) A text editor window should pop up with the following source code (except
with your actual name):
package csci2011.Lab4;
Page 2 of 4
Dept. CSIT, APSU Spring 2024
/**
*
* @author Kriti Chauhan
*/
public interface MessageSender {
}
6. Add method headers to the MessageSender interface.
(a) Add a method header for a void return method called sendMessage that takes
two arguments of type String, one for recipient, and one for message.
(b) Add a method header for a void return method called receiveMessage that
takes two String arguments, one for sender and one for message.
7. Create a Java class file for an abstract class called
AbstractCommunicationDevice that implements the MessageSender
interface.
a) Add an instance variable deviceName to represent the name of the
communication device.
b) Provide a constructor to initialize the deviceName variable in the abstract class
called AbstractCommunicationDevice.
c) Implement methods declared in the MessageSender interface. A possible
implementation would be to print out information to the console.
8. Create another abstract Java class called Smartphone that extends
AbstractCommunicationDevice.
a) Declare an instance variable batteryLevel to represent the battery level of
the smartphone.
b) Implement a method checkBatteryLevel() to display the current battery level.
9. Create a Java class file for the concrete class AndroidPhone that extends
Smartphone. It should also implement the interface Mammoth.
(a) Implement a parameterized constructor that initializes the device name and
battery level of the Android phone.
(b) Override the sendMessage(String recipient, String message)
method to display a message specific to sending messages from an Android
phone.
Page 3 of 4
Dept. CSIT, APSU Spring 2024
(c) Override the receiveMessage(String sender, String message)
method to display a message specific to receiving messages on an Android
phone.
10. Add code in the main() method of main class file to test your implementation.
a) Create an instance of the AndroidPhone class.
b) Send and receive messages using the Android phone.
c) Display the battery level of the smartphone.
d) Your output might look like this:
Samsung Galaxy is sending a message to Alice: Lunch today at 12.
Samsung Galaxy received a message from Bob: What time is the
meeting today?
Samsung Galaxy is sending a message to Bob: Meeting at 2:30
Battery level: 80%
11. Ensure that your code follows good coding practices, including appropriate naming
conventions, comments, and indentation.
12. Hand in all your source files to the D2L assignment dropbox called Lab 4. The
comments in each file should contain your name, CSCI 2011 Lab 4, and a description of
what the class defined in the file does

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!