Question
Create a project in NetBeans. Create two classes, Pill and Morpheus, separately. Save them to Pill.java and Morpheus.java. Code the two classes as specified as
Create a project in NetBeans. Create two classes, Pill and Morpheus, separately. Save them to Pill.java and Morpheus.java. Code the two classes as specified as follows. Compile and run to test the program.
Pill Class
This class represents a pill. private data fields
o a private String data field named color o a private double data field named size o a private String data field named efficacy o a private boolean data field named status
-
a constructor that creates a pill with specified color and size
-
the get / set methods for the data fields color, size, efficacy
-
the isTaken and set methods for the data field status
-
a printInfo method that print all the information about the pill
o a pill with size smaller than 2.0 is a Small pill, otherwise Large o a pill with status equals true means the pill is Taken, otherwise (i.e. false) Available
Morpheus Class This is the class containing the main method that does the following
-
use the constructor to create two Pill objects named redPill and bluePill, with color red and blue
-
use setter methods to set size and status for each of the two pills to be 1.414 and false
-
use setter method to set efficacy for redPill to be Tracing for unplugging this human., and for
bluePill to be Sending back to the Matrix to sleep.
-
show some prompt messages, including to print pill information by calling the printInfo method of the
two pills
-
keep reading choice from keyboard: 1 for blue pill, 2 for red pill
o if the input is 1, then display message No Neo, you gotta try harder., ask to choose again o if the input is 2, then show a message asking for confirmation (1 means Yes; 2 means No)
if the input is 2, show OK, think about it then decide., then ask to choose again if the input is 1, show Follow Me, change the redPills status to true (i.e. Taken), then
PROG23199 Winter 2020 Assignment 1
the program terminates
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started