Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Medicine { private double capacity; //in mL private String name; private boolean isLiquid; public Medicine() { } //TODO 2 (3 pts) Create a

public class Medicine {

private double capacity; //in mL

private String name;

private boolean isLiquid;

public Medicine() {

}

//TODO 2 (3 pts) Create a constructor that sets all the instance variables in this class

//through its arguments

public String toString() {

//TODO 4 (4 pts) Fix this to that it returns a string like this:

//[Name: Advil] [Capacity: 330mL] [Not liquid]

//OR

//[Name: Advil] [Capacity: 330mL] [Liquid]

return "";

}

}

_________________________________________________________________________________

public class Runner {

public static void main(String[] args) {

//TODO 1 (2 pts) execute the run() method below without modifying its signature

}

public void run() {

//TODO 3 (2 pts) Using the constructor you created in TODO2,

//Create a medicine called "Advil" that is in liquid form

// and has a capacity of 300mL and store it in variable medicine

//TODO 5 (2 pt) print out information of medicine using toString()

//TODO 6 (3 pts) Change "medicine" from liquid to tablet (not liquid)

//create any getters and setters as needed

//TODO 7 (2 pts) Print it out again

//TODO 8 (3 pts) Create a new medicine in variable medicine2

//Make sure you create it using the default constructor.

//The default constructor of Medicine needs to be modified so you

//can achieve the output of TODO9 (see next todo)

//TODO 9 (2 pts) print medicine2 using toString(). Make sure it

//prints the following:

//[Name: Generic] [Capacity: 0.0mL] [Not liquid]

}

}

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions