Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this assignment is for you to write all of your own comments and code. You will also get some practice using enumeration.

The purpose of this assignment is for you to write all of your own comments and code. You will also get some practice using enumeration.

Problem Description

You are to implement a program which tracks the state of water. This will be implemented using the UML shown below.

image text in transcribed

The temperature String passed to the constructor will be something like "100C" for 100 degrees Centigrade or "-20F" for minus 20 degrees Fahrenheight. You need to take that String and set your instance variables in the constructor.

The getState method returns one of the MatterState enumerated types (See Special Topic 5.4 Enumeration Types on pag 206). In UML, the values of the enumerated types are given by the attributes. You don't need to use the text > at all in your Java code. It is just a way of indicating that the diagram represents an enumerated type.

Hints:

You might want to use the substring method of the Stringobject.

You can print the MatterState enumerated type directly.

Enumerated types, also called enum, have a template under eclipse like when you create a class.

The enumerated type will have a separate source file.

Requirement:

Do NOT convert the provided temperature, either upon receiving it or when checking the matter state. While this may be more efficient and clean, this assignment expects you to deal with the data, as provided, to determine the state.

Getting Started

We are going to do this exercise by writing the object that solves the problem first (in a source file called WaterState.javaand MatterState.java) and then testing it using code we write into Program.java. Using the techniques shown on the web page titled "How to Start Every Project in this Class" create a source file called WaterState.java as well as a file called MatterState.java and Program.java.

Starting this week we don't have any code to copy for the assignment. You get to do it all! Don't forget to provide proper Javadoc documentation as well as implement all of the methods in the UML diagram.

Your Program.java should contain code to test your WaterState and MatterState objects. Be sure to test the cases where you have Fahrenheit and Celcius temperature scales (i.e. the edge cases).

I NEED the program to check for both celcius and Fahrenheit.

WaterState Cenumeration MatterState waterTemperature: double + getState): MatterState +WaterState(temperature: String) GAS LIQUID SOLID Program +mainfargs: String): void WaterState Cenumeration MatterState waterTemperature: double + getState): MatterState +WaterState(temperature: String) GAS LIQUID SOLID Program +mainfargs: String): void

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

help asp

Answered: 1 week ago