Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/** * A class for a Person object that stores the soda name, sugar content, and volume * * You should create the following methods:

/**

* A class for a Person object that stores the soda name, sugar content, and volume

*

* You should create the following methods:

* - Create constructor that takes in the three class attributes

* - Create getName method that returns the name

* - Create getSugar method that returns the sugar content in grams

* - Create getVolume method that returns the sugar content in mL

*/

public class Soda

{

/**

* name: name of the Soda

* sugar: number of grams of sugar in volume

* volume: volume of container

*/

private String name;

private int sugar;

private int volume;

/**

Create constructor method with 3 parameters to initialize

the 3 instance variables (see SodaTester.java as a guide).

The order should of input should be name, sugar content, volume

*/

//-----------Start below here. To do: approximate lines of code = 4

//

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

/**

Create public method getName() that returns the soda's name

*/

//-----------Start below here. To do: approximate lines of code = 2

//

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

/**

Create public method getSugar() that returns the amount of sugar

*/

//-----------Start below here. To do: approximate lines of code = 2

//

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

/**

Create public method getVolume() method that returns volume

*/

//-----------Start below here. To do: approximate lines of code = 2

//

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

}

********************************************************************************************************

import java.util.ArrayList;

/**

* Tests the Soda class. You also must complete the getMinSugar method.

*/

public class SodaTester

{

/**

* Returns the Soda object from the list of sodas that has the minimum

* amount of sugar. Return null if the array list is empty.

*

* @param sodas An array list of sodas

* @return The soda with the minimum sugar content

*/

public static Soda getMinSugar(ArrayList sodas) {

//-----------Start below here. To do: approximate lines of code = 5

//

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

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_2

Step: 3

blur-text-image_3

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Explain the importance of

Answered: 1 week ago