|
1 | 1 | package DataStructuring;
|
2 | 2 | import java.util.*;
|
| 3 | +import java.util.regex.Matcher; |
| 4 | +import java.util.regex.Pattern; |
3 | 5 |
|
4 | 6 | public class DataStructures2 {
|
5 | 7 | static void Identity(ArrayList<Object>array){
|
@@ -34,6 +36,35 @@ public void ObjectFilter(HashMap<Object,Object>Hash){
|
34 | 36 | }
|
35 | 37 | }
|
36 | 38 |
|
| 39 | + interface Thoughts{ |
| 40 | + Object express(Object inp); |
| 41 | + } |
| 42 | + |
| 43 | + interface Expression{ |
| 44 | + Object express(Object str); |
| 45 | + } |
| 46 | + |
| 47 | + interface Digits{ |
| 48 | + Object count(int inp); |
| 49 | + } |
| 50 | + |
| 51 | + public static void WhatFeel(Object num, Expression feel){ |
| 52 | + Object result = feel.express(num); |
| 53 | + System.out.println(result); |
| 54 | + } |
| 55 | + |
| 56 | + public static void WhatThink(Object inp, Thoughts idea){ |
| 57 | + Object result = idea.express(inp); |
| 58 | + System.out.println(result); |
| 59 | + } |
| 60 | + |
| 61 | + public static void WhatCount(int inp, Digits style){ |
| 62 | + Object result = style.count(inp); |
| 63 | + System.out.println(result); |
| 64 | + } |
| 65 | + |
| 66 | + |
| 67 | + |
37 | 68 | public static void main (String args[]){
|
38 | 69 | ArrayList<Object> Normal = new ArrayList<Object>();
|
39 | 70 | Normal.add(901);
|
@@ -204,6 +235,42 @@ else if (ft.equals("Fuck")){
|
204 | 235 | System.out.println("It's alright!");
|
205 | 236 | } */
|
206 | 237 |
|
| 238 | + //Patterns |
| 239 | + Pattern secretcode = Pattern.compile("Gaelissexy",Pattern.CASE_INSENSITIVE); |
| 240 | + Matcher Match = secretcode.matcher("ohhh hahahah gaelis gaelissexy"); |
| 241 | + boolean thereis = Match.find(); |
| 242 | + if (thereis){ |
| 243 | + System.out.println("Oh my god, a stalker to Gael!"); |
| 244 | + } |
| 245 | + else{ |
| 246 | + System.out.println("What is this? haha"); |
| 247 | + } |
| 248 | + |
| 249 | + //Java Lambda |
| 250 | + Expression happy = (x) -> x + " A sign of happiness!"; |
| 251 | + Expression sad = (x) -> x + " A sign of sadness huhu."; |
| 252 | + WhatFeel(69, sad); |
| 253 | + |
| 254 | + Thoughts Calculating = (x) -> { |
| 255 | + if (x.toString().contains("hard")){ |
| 256 | + x = "This is a sign of effort, commitment, and perseverance!"; |
| 257 | + } |
| 258 | + else if (x.toString().contains("chill")){ |
| 259 | + x = "This is a sign that you are lacking, uncommitted, and have no direction!"; |
| 260 | + } |
| 261 | + return x; |
| 262 | + }; |
| 263 | + |
| 264 | + WhatThink("This Programming journey seems both easy AND hard!", Calculating); |
| 265 | + |
| 266 | + |
| 267 | + |
| 268 | + Digits CountingOne = (x) -> { |
| 269 | + int result = x-1; |
| 270 | + return result + " is the distance of your input to 1"; |
| 271 | + }; |
207 | 272 |
|
| 273 | + WhatCount(1231, CountingOne); |
208 | 274 | }
|
| 275 | + |
209 | 276 | }
|
0 commit comments