Skip to content

Commit

Permalink
OTher about me stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
4disease committed Dec 13, 2021
1 parent 8cf4bb0 commit b32a442
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;

import com.example.sping_portfolio.controllers.KiraLightSequence;
// Built using article: https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/mvc.html
// or similar: https://asbnotebook.com/2020/04/11/spring-boot-thymeleaf-form-validation-example/
@Controller
Expand Down Expand Up @@ -85,9 +85,25 @@ public String quotes(Model model) throws IOException, InterruptedException, Pars
//convert response.body() to java hash map
var aboutkira = new ObjectMapper().readValue(response.body(), HashMap.class);

KiraLightSequence gradshow = new KiraLightSequence("0101 0101 0101");
String returnString1 = gradshow.getSequence();

gradshow.changeSequence("0011 0011 0011");
String returnString2 = gradshow.getSequence();

String returnString3 = gradshow.insertSegment("1111 1111", 4);
String returnString4 = KiraLightSequence.newSequence("1100000111", "11");
int returnString5 = KiraLightSequence.squareRoot(4, 0);

String returnString = "a) " + returnString1 + "\n" +
"b) " + returnString2 + "\n" +
"c) " + returnString3 + "\n" +
"d) " + returnString4 + "\n" +
"e) " + returnString5;

//pass stats to view
model.addAttribute("aboutkira", aboutkira);
model.addAttribute("returnString", returnString);


return "AboutUs/aboutkira";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.example.sping_portfolio.controllers;

public class KiraLightSequence {
String sequence = "";

public KiraLightSequence(String seq)
{
sequence = seq;
}

public void display(){
System.out.println("The light sequence is " + this.sequence);
}

public String getSequence(){
String string = this.sequence;
return string;
}

public void changeSequence(String seq)
{
this.sequence = seq;
}

public String insertSegment(String segment, int ind)
{
String newSequence = this.sequence.substring(0, ind + 1)
+ segment
+ this.sequence.substring(ind + 1);

return newSequence;

}

public static String newSequence(String oldSeq, String segment){
int index = oldSeq.indexOf(segment);
String newSeq = oldSeq.substring(0, index) + oldSeq.substring(index + segment.length());

return newSeq;
}

public static int squareRoot(double a, double b){
double root = (Math.sqrt(a*a + b*b));
return (int)root;
}


public static void main(String args[])
{
KiraLightSequence gradshow = new KiraLightSequence("0101 0101 0101");
gradshow.display();

gradshow.changeSequence("0011 0011 0011");
gradshow.display();

System.out.println(gradshow.insertSegment("1111 1111", 4));
System.out.println(newSequence("1100000111", "11"));
System.out.println(squareRoot(4, 0));
}
}
66 changes: 63 additions & 3 deletions src/main/resources/templates/AboutUs/aboutkira.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
</script>
</div></head>

<body><div layout:fragment="content" th:remove="tag">
<td th:text="${aboutkira.content}">Rank</td>

<body style="background-color:lightgreen;"><div layout:fragment="content" th:remove="tag">
<!-- <table>-->
<!-- <td th:text="${aboutkira.content}">Rank</td>-->
<!-- </table>-->
<div style=" left: auto; top: 40px;">
<img th:src="@{/images/kira.png}" width="auto" height="200" onclick="imagefun()" id="getImage"; />
</div>
Expand All @@ -41,6 +42,65 @@
Profile
</button>
</div>

<pre style="background-color:lightgreen;"><code>
public class LightSequence {
String sequence = "";

public LightSequence(String seq)
{
sequence = seq;
}

public void display(){
System.out.println("The light sequence is " + this.sequence);
}

public void changeSequence(String seq)
{
this.sequence = seq;
}

public String insertSegment(String segment, int ind)
{
String newSequence = this.sequence.substring(0, ind + 1)
+ segment
+ this.sequence.substring(ind + 1);

return newSequence;

}

public static String newSequence(String oldSeq, String segment){
int index = oldSeq.indexOf(segment);
String newSeq = oldSeq.substring(0, index) + oldSeq.substring(index + segment.length());

return newSeq;
}

public static int squareRoot(double a, double b){
double root = (Math.sqrt(a*a + b*b));
return (int)root;
}

public static void main(String args[])
{
LightSequence gradshow = new LightSequence("0101 0101 0101");
gradshow.display();

gradshow.changeSequence("0011 0011 0011");
gradshow.display();

System.out.println(gradshow.insertSegment("1111 1111", 4));
System.out.println(newSequence("1100000111", "11"));
System.out.println(squareRoot(4, 0));
}
}
</code></pre>

<a style="background-color:lightgreen;" th:text="${returnString}">Code Run</a>


</div>
</body>

Expand Down

0 comments on commit b32a442

Please sign in to comment.