Browse Source

Der sechste Commit. Der Bmi wird jetzt per Funktion berechnet, damit

diese auch für Testzwecke verwendet werden kann. auch wurde eine
Testklasse erstellt mit einem Testfall.
master
MSeibert97 5 years ago
parent
commit
29607c8435
  1. 133
      .idea/workspace.xml
  2. 6
      src/FitnessTest_M.java
  3. 29
      src/FitnessTest_M_Test.java

133
.idea/workspace.xml

@ -2,6 +2,7 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="db773f9a-00fd-4a2d-a6a9-bbfafdd60b01" name="Default Changelist" comment=""> <list default="true" id="db773f9a-00fd-4a2d-a6a9-bbfafdd60b01" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/FitnessTest_M_Test.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/FitnessTest_M.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/FitnessTest_M.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/FitnessTest_M.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/FitnessTest_M.java" afterDir="false" />
</list> </list>
@ -20,12 +21,10 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Main.java"> <entry file="file://$PROJECT_DIR$/src/Main.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2533">
<state relative-caret-position="2465">
<caret line="149" selection-start-line="149" selection-end-line="149" /> <caret line="149" selection-start-line="149" selection-end-line="149" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#2492#2625#0" expanded="true" />
<element signature="e#2624#2625#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -34,15 +33,28 @@
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/FitnessTest_M.java"> <entry file="file://$PROJECT_DIR$/src/FitnessTest_M.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="199">
<caret line="123" column="47" lean-forward="true" selection-start-line="123" selection-start-column="47" selection-end-line="123" selection-end-column="47" />
<state relative-caret-position="230">
<caret line="110" column="59" lean-forward="true" selection-start-line="110" selection-start-column="59" selection-end-line="110" selection-end-column="59" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#1775#2237#0" expanded="true" />
<element signature="e#2236#2237#0" expanded="true" />
<element signature="e#2664#3127#0" expanded="true" />
<element signature="e#3126#3127#0" expanded="true" />
<element signature="e#5263#5264#0" expanded="true" />
<element signature="e#5244#5245#0" expanded="true" />
<element signature="e#5297#5298#0" expanded="true" />
<element signature="e#5356#5357#0" expanded="true" />
<element signature="e#5411#5412#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/FitnessTest_M_Test.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-88">
<caret line="9" column="11" selection-start-line="9" selection-start-column="11" selection-end-line="9" selection-end-column="11" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#142#143#0" expanded="true" />
<element signature="e#192#193#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -97,14 +109,21 @@
<option value="$PROJECT_DIR$/src/Tage_DTest.java" /> <option value="$PROJECT_DIR$/src/Tage_DTest.java" />
<option value="$PROJECT_DIR$/src/Tage_D.java" /> <option value="$PROJECT_DIR$/src/Tage_D.java" />
<option value="$PROJECT_DIR$/src/Main.java" /> <option value="$PROJECT_DIR$/src/Main.java" />
<option value="$PROJECT_DIR$/src/FitnessTest_M_Test.java" />
<option value="$PROJECT_DIR$/src/FitnessTest_M.java" /> <option value="$PROJECT_DIR$/src/FitnessTest_M.java" />
</list> </list>
</option> </option>
</component> </component>
<component name="MavenProjectNavigator">
<treeState>
<expand />
<select />
</treeState>
</component>
<component name="ProjectFrameBounds" extendedState="6"> <component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="792" /> <option name="x" value="792" />
<option name="width" value="815" />
<option name="height" value="878" />
<option name="width" value="816" />
<option name="height" value="879" />
</component> </component>
<component name="ProjectLevelVcsManager"> <component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" /> <ConfirmationsSetting value="2" id="Add" />
@ -114,6 +133,8 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scope" />
<pane id="PackagesPane" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<expand> <expand>
@ -130,8 +151,6 @@
<select /> <select />
</subPane> </subPane>
</pane> </pane>
<pane id="PackagesPane" />
<pane id="Scope" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
@ -175,13 +194,6 @@
</option> </option>
</component> </component>
<component name="RunManager" selected="Application.FitnessTest_M"> <component name="RunManager" selected="Application.FitnessTest_M">
<configuration name="D_Test1" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="D_Test1" />
<module name="Alpha" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="FitnessTest_M" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> <configuration name="FitnessTest_M" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="FitnessTest_M" /> <option name="MAIN_CLASS_NAME" value="FitnessTest_M" />
<module name="Alpha" /> <module name="Alpha" />
@ -212,20 +224,29 @@
<option name="Make" enabled="true" /> <option name="Make" enabled="true" />
</method> </method>
</configuration> </configuration>
<configuration name="FitnessTest_M_Test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
<module name="Alpha" />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="FitnessTest_M_Test" />
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<list> <list>
<item itemvalue="Application.D_Geburtstag" />
<item itemvalue="Application.D_Test1" />
<item itemvalue="Application.FitnessTest_M" />
<item itemvalue="Application.Main" /> <item itemvalue="Application.Main" />
<item itemvalue="Application.Quiz_Spiel" /> <item itemvalue="Application.Quiz_Spiel" />
<item itemvalue="Application.Tage_D" /> <item itemvalue="Application.Tage_D" />
<item itemvalue="JUnit.FitnessTest_M_Test" />
</list> </list>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Application.FitnessTest_M" /> <item itemvalue="Application.FitnessTest_M" />
<item itemvalue="JUnit.FitnessTest_M_Test" />
<item itemvalue="Application.Main" /> <item itemvalue="Application.Main" />
<item itemvalue="Application.Quiz_Spiel" /> <item itemvalue="Application.Quiz_Spiel" />
<item itemvalue="Application.Tage_D" /> <item itemvalue="Application.Tage_D" />
<item itemvalue="Application.D_Test1" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
@ -436,7 +457,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1563267787360</updated> <updated>1563267787360</updated>
</task> </task>
<option name="localTasksCounter" value="27" />
<task id="LOCAL-00027" summary="Der fünfte Commit. Es gibt nun unterschiedliche PopUp Fenster, die von dem Wert des BMI's abhängen.">
<created>1563268520678</created>
<option name="number" value="00027" />
<option name="presentableId" value="LOCAL-00027" />
<option name="project" value="LOCAL" />
<updated>1563268520678</updated>
</task>
<option name="localTasksCounter" value="28" />
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
@ -444,39 +472,40 @@
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="-7" y="-7" width="1295" height="695" extended-state="6" /> <frame x="-7" y="-7" width="1295" height="695" extended-state="6" />
<editor active="true" />
<layout> <layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.254251" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.26234818" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Image Layers" order="2" /> <window_info id="Image Layers" order="2" />
<window_info id="Designer" order="3" /> <window_info id="Designer" order="3" />
<window_info id="UI Designer" order="4" /> <window_info id="UI Designer" order="4" />
<window_info id="Capture Tool" order="5" /> <window_info id="Capture Tool" order="5" />
<window_info id="Favorites" order="6" side_tool="true" /> <window_info id="Favorites" order="6" side_tool="true" />
<window_info anchor="bottom" id="Messages" order="0" weight="0.3268206" />
<window_info anchor="bottom" id="Messages" order="0" sideWeight="0.49635628" weight="0.3268206" />
<window_info anchor="bottom" id="Message" order="1" /> <window_info anchor="bottom" id="Message" order="1" />
<window_info anchor="bottom" id="Find" order="2" weight="0.3290461" /> <window_info anchor="bottom" id="Find" order="2" weight="0.3290461" />
<window_info anchor="bottom" id="Run" order="3" visible="true" weight="0.124333926" />
<window_info active="true" anchor="bottom" id="Run" order="3" sideWeight="0.4979757" visible="true" weight="0.28596804" />
<window_info anchor="bottom" id="Debug" order="4" weight="0.3997344" /> <window_info anchor="bottom" id="Debug" order="4" weight="0.3997344" />
<window_info anchor="bottom" id="Cvs" order="5" weight="0.25" /> <window_info anchor="bottom" id="Cvs" order="5" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="6" weight="0.4" /> <window_info anchor="bottom" id="Inspection" order="6" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="7" /> <window_info anchor="bottom" id="TODO" order="7" />
<window_info anchor="bottom" id="Docker" order="8" show_stripe_button="false" /> <window_info anchor="bottom" id="Docker" order="8" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" order="9" weight="0.32802126" />
<window_info anchor="bottom" id="Version Control" order="9" weight="0.3268206" />
<window_info anchor="bottom" id="Database Changes" order="10" /> <window_info anchor="bottom" id="Database Changes" order="10" />
<window_info anchor="bottom" id="Terminal" order="11" weight="0.3290461" /> <window_info anchor="bottom" id="Terminal" order="11" weight="0.3290461" />
<window_info anchor="bottom" id="Event Log" order="12" side_tool="true" />
<window_info anchor="bottom" id="Event Log" order="12" sideWeight="0.5020243" side_tool="true" visible="true" weight="0.28596804" />
<window_info anchor="bottom" id="Java Enterprise" order="13" /> <window_info anchor="bottom" id="Java Enterprise" order="13" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Palette" order="3" /> <window_info anchor="right" id="Palette" order="3" />
<window_info anchor="right" id="Theme Preview" order="4" /> <window_info anchor="right" id="Theme Preview" order="4" />
<window_info anchor="right" id="Maven" order="5" />
<window_info anchor="right" id="Capture Analysis" order="6" />
<window_info anchor="right" id="Palette&#9;" order="7" />
<window_info anchor="right" id="Database" order="8" />
<window_info anchor="right" id="CDI" order="9" />
<window_info active="true" anchor="right" id="Coverage" order="10" side_tool="true" visible="true" weight="0.32995737" />
<window_info anchor="right" id="Capture Analysis" order="5" />
<window_info anchor="right" id="Palette&#9;" order="6" />
<window_info anchor="right" id="Database" order="7" />
<window_info anchor="right" id="CDI" order="8" />
<window_info active="true" anchor="right" id="Coverage" order="9" side_tool="true" visible="true" weight="0.32995737" />
<window_info anchor="right" id="Maven" order="10" weight="0.32955465" />
</layout> </layout>
<layout-to-restore> <layout-to-restore>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.14712153" /> <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.14712153" />
@ -534,7 +563,8 @@
<MESSAGE value="Der zweite commit, in welche ich eine Ungültigkeitsabfrage in meiner Fitnesstest Klasse eingebaut habe&#10;welche prüft, ob in den Textfields eine Zahl, mit oder ohne Nachkommastellen, eingegeben wurde." /> <MESSAGE value="Der zweite commit, in welche ich eine Ungültigkeitsabfrage in meiner Fitnesstest Klasse eingebaut habe&#10;welche prüft, ob in den Textfields eine Zahl, mit oder ohne Nachkommastellen, eingegeben wurde." />
<MESSAGE value="Der dritte commit, in welcher ich die Verwendung eines JPanels gegen einen NoLayout ausgetauscht habe,&#10;sodass ich die Bounds eigenständig festlegen darf. Die JLabels/Textfields wurden Positionen festgelegt.&#10;Die height/weight Textfields haben nun einen Nutzen. Neuer JButton &quot;BMI berechnen&quot; nimmt Floats von den&#10;Textfields und gibt den BMI in der Konsole aus." /> <MESSAGE value="Der dritte commit, in welcher ich die Verwendung eines JPanels gegen einen NoLayout ausgetauscht habe,&#10;sodass ich die Bounds eigenständig festlegen darf. Die JLabels/Textfields wurden Positionen festgelegt.&#10;Die height/weight Textfields haben nun einen Nutzen. Neuer JButton &quot;BMI berechnen&quot; nimmt Floats von den&#10;Textfields und gibt den BMI in der Konsole aus." />
<MESSAGE value="Der vierte commit. Der BMI Wert wird nun durch ein PopUp Fenster&#10;angezeigt und nicht mehr durch die Konsole." /> <MESSAGE value="Der vierte commit. Der BMI Wert wird nun durch ein PopUp Fenster&#10;angezeigt und nicht mehr durch die Konsole." />
<option name="LAST_COMMIT_MESSAGE" value="Der vierte commit. Der BMI Wert wird nun durch ein PopUp Fenster&#10;angezeigt und nicht mehr durch die Konsole." />
<MESSAGE value="Der fünfte Commit. Es gibt nun unterschiedliche PopUp Fenster, die von dem Wert des BMI's abhängen." />
<option name="LAST_COMMIT_MESSAGE" value="Der fünfte Commit. Es gibt nun unterschiedliche PopUp Fenster, die von dem Wert des BMI's abhängen." />
</component> </component>
<component name="com.intellij.coverage.CoverageDataManagerImpl"> <component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/Alpha_GOGS$Main.ic" NAME="Main Coverage Results" MODIFIED="1563229577210" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" /> <SUITE FILE_PATH="coverage/Alpha_GOGS$Main.ic" NAME="Main Coverage Results" MODIFIED="1563229577210" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
@ -610,27 +640,36 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Main.java"> <entry file="file://$PROJECT_DIR$/src/Main.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2533">
<state relative-caret-position="2465">
<caret line="149" selection-start-line="149" selection-end-line="149" /> <caret line="149" selection-start-line="149" selection-end-line="149" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#2492#2625#0" expanded="true" />
<element signature="e#2624#2625#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/FitnessTest_M_Test.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-88">
<caret line="9" column="11" selection-start-line="9" selection-start-column="11" selection-end-line="9" selection-end-column="11" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#142#143#0" expanded="true" />
<element signature="e#192#193#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/FitnessTest_M.java"> <entry file="file://$PROJECT_DIR$/src/FitnessTest_M.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="199">
<caret line="123" column="47" lean-forward="true" selection-start-line="123" selection-start-column="47" selection-end-line="123" selection-end-column="47" />
<state relative-caret-position="230">
<caret line="110" column="59" lean-forward="true" selection-start-line="110" selection-start-column="59" selection-end-line="110" selection-end-column="59" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
<element signature="e#1775#2237#0" expanded="true" />
<element signature="e#2236#2237#0" expanded="true" />
<element signature="e#2664#3127#0" expanded="true" />
<element signature="e#3126#3127#0" expanded="true" />
<element signature="e#5263#5264#0" expanded="true" />
<element signature="e#5244#5245#0" expanded="true" />
<element signature="e#5297#5298#0" expanded="true" />
<element signature="e#5356#5357#0" expanded="true" />
<element signature="e#5411#5412#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>

6
src/FitnessTest_M.java

@ -108,7 +108,7 @@ public class FitnessTest_M extends JFrame {
if(b.getSource() == bmi_rechnen) { if(b.getSource() == bmi_rechnen) {
float height = Float.parseFloat(height_tf.getText()); float height = Float.parseFloat(height_tf.getText());
float weight = Float.parseFloat(weight_tf.getText()); float weight = Float.parseFloat(weight_tf.getText());
int bmi = (int) (weight / (height*height));
int bmi = calculateBmi(height, weight);
if(bmi < 19) { if(bmi < 19) {
JOptionPane.showMessageDialog(null, JOptionPane.showMessageDialog(null,
"Ihr BMI: " + bmi + " \nUntergewicht!", "Ihr BMI: " + bmi + " \nUntergewicht!",
@ -146,5 +146,9 @@ public class FitnessTest_M extends JFrame {
public static void main(String[] args) { public static void main(String[] args) {
FitnessTest_M M = new FitnessTest_M(); FitnessTest_M M = new FitnessTest_M();
} }
public int calculateBmi(float height, float weight) {
return (int) (weight / (height*height));
}
} }

29
src/FitnessTest_M_Test.java

@ -0,0 +1,29 @@
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
public class FitnessTest_M_Test {
private FitnessTest_M fitnessTest_M;
@Before
public void setup() {
fitnessTest_M = new FitnessTest_M();
}
@Test
public void normalBmi() {
//arrange
FitnessTest_M fitnessTest_M = new FitnessTest_M();
float height = (float) 1.70;
float weight = 70;
int expectedResult = 24;
//act
int bmiResult = fitnessTest_M.calculateBmi(height, weight);
//assert
assertThat("", bmiResult, equalTo(expectedResult));
}
}
Loading…
Cancel
Save