Skip to content
Snippets Groups Projects
Commit 675d013f authored by Kloosterboer, W.A. (Walter, Student B-BIT)'s avatar Kloosterboer, W.A. (Walter, Student B-BIT)
Browse files

Added structure

parent 5cd99c3c
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
\ No newline at end of file
......@@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nl.utwente.di</groupId>
<artifactId>bookQuote</artifactId>
<artifactId>temperatureCalculator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
......
package nl.utwente.di.bookQuote;
import java.util.HashMap;
public class Quoter {
private static HashMap<String, Double> bookPrices = new HashMap<>();
public Quoter() {
bookPrices.put("1", 10.0);
bookPrices.put("2", 45.0);
bookPrices.put("3", 20.0);
bookPrices.put("4", 35.0);
bookPrices.put("5", 50.0);
bookPrices.put("others", 0.0);
}
public double getBookPrice(String isbn) {
if (bookPrices.containsKey(isbn)) {
return bookPrices.get(isbn);
} else {
return 0;
}
}
}
package nl.utwente.di.temperatureCalculator;
public class Calculator {
public double getTemperature(String temperature) {
try {
double temperatureInt = Integer.parseInt(temperature);
return (((temperatureInt * 9) / 5) + 32);
} catch (Exception e) {
return 0;
}
}
}
package nl.utwente.di.bookQuote;
package nl.utwente.di.temperatureCalculator;
import java.io.*;
import jakarta.servlet.*;
......@@ -7,12 +7,12 @@ import jakarta.servlet.http.*;
/** Example of a Servlet that gets an ISBN number and returns the book price
*/
public class BookQuote extends HttpServlet {
public class TemperatureCalculator extends HttpServlet {
private static final long serialVersionUID = 1L;
private Quoter quoter;
private Calculator calculator;
public void init() throws ServletException {
quoter = new Quoter();
calculator = new Calculator();
}
public void doGet(HttpServletRequest request,
......@@ -21,7 +21,7 @@ public class BookQuote extends HttpServlet {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Book Quote";
String title = "Temperature Calculator";
// Done with string concatenation only for the demo
// Not expected to be done like this in the project
......@@ -33,9 +33,9 @@ public class BookQuote extends HttpServlet {
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>" + title + "</H1>\n" +
" <P>ISBN number: " +
request.getParameter("isbn") + "\n" +
request.getParameter("temperature") + "\n" +
" <P>Price: " +
quoter.getBookPrice(request.getParameter("isbn")) +
calculator.getTemperature(request.getParameter("temperature")) +
"</BODY></HTML>");
}
}
......@@ -5,7 +5,7 @@
https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
version="6.0">
<display-name>di.bookQuote</display-name>
<display-name>di.Temperature</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
......@@ -16,13 +16,13 @@
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description>BookQuote Servlet</description>
<display-name>BookQuote</display-name>
<servlet-name>BookQuote</servlet-name>
<servlet-class>nl.utwente.di.bookQuote.BookQuote</servlet-class>
<description>Temperature Servlet</description>
<display-name>Temperature</display-name>
<servlet-name>Temperature</servlet-name>
<servlet-class>nl.utwente.di.temperatureCalculator.TemperatureCalculator</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BookQuote</servlet-name>
<url-pattern>/bookQuote</url-pattern>
<servlet-name>Temperature</servlet-name>
<url-pattern>/Temperature</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
......@@ -9,10 +9,10 @@
</head>
<body>
<h1>Web Book Quote Application</h1>
<h1>Celsius to Fahrenheit Calculator</h1>
<form ACTION="./bookQuote">
<p>Enter ISBN number: <input TYPE="TEXT" NAME="isbn"></p>
<form ACTION="./temperatureCalculator">
<p>Enter temperature in Celsius: <input TYPE="TEXT" NAME="temperature"></p>
<input TYPE="SUBMIT">
</form>
......
package nl.utwente.di.bookQuote;
import nl.utwente.di.temperatureCalculator.Calculator;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class TestQuoter {
public class TestCalculator {
@Test
public void testBook1() throws Exception {
Quoter quoter = new Quoter();
double price = quoter.getBookPrice("1");
Calculator calculator = new Calculator();
double price = calculator.getTemperature("1");
Assertions.assertEquals(10.0, price, 0.0, "Price of book 1");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment