q
This commit is contained in:
@@ -3,8 +3,8 @@
|
|||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/BP" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/WS22_23/BP" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/EidP" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/WS22_23/EidP" isTestSource="false" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package P3;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
public class AtomicLongComparable extends AtomicLong {
|
||||||
|
|
||||||
|
AtomicLongComparable(long input){
|
||||||
|
set(input);
|
||||||
|
}
|
||||||
|
AtomicLongComparable(){
|
||||||
|
set(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compare(AtomicLongComparable in1){
|
||||||
|
if(get() < in1.get()){
|
||||||
|
return -1;
|
||||||
|
} else if (get() > in1.get() ) {
|
||||||
|
return 1;
|
||||||
|
}else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package P3;
|
||||||
|
|
||||||
|
import P2.Brot;
|
||||||
|
import P2.Einkaufswagen;
|
||||||
|
import P2.Nahrungsmittel;
|
||||||
|
import P2.Wurst;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class Programm {
|
||||||
|
|
||||||
|
static Scanner sc = new Scanner(System.in);
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
|
||||||
|
boolean end = false;
|
||||||
|
|
||||||
|
int number = 0;
|
||||||
|
|
||||||
|
|
||||||
|
List<Integer> list = new LinkedList();
|
||||||
|
|
||||||
|
|
||||||
|
while (!end) {
|
||||||
|
System.out.println("Add number: 1:Yes, 2:No");
|
||||||
|
System.out.println("");
|
||||||
|
|
||||||
|
try {
|
||||||
|
number = sc.nextInt();
|
||||||
|
}catch (InputMismatchException ime){
|
||||||
|
sc.next();
|
||||||
|
System.out.println("Mach ne zahl du hurensohn");
|
||||||
|
//ime.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
addNum(list);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
startGame(list);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static List<Integer> addNum(List<Integer> list){
|
||||||
|
while(true){
|
||||||
|
try {
|
||||||
|
list.add(sc.nextInt());
|
||||||
|
return list;
|
||||||
|
}catch (InputMismatchException ime){
|
||||||
|
sc.next();
|
||||||
|
System.out.println("Mach ne zahl du hurensohn");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void startGame(List<Integer> list){
|
||||||
|
|
||||||
|
Iterator<Integer> iterator = list.iterator();
|
||||||
|
boolean won = true;
|
||||||
|
|
||||||
|
while(iterator.hasNext()){
|
||||||
|
System.out.println("Next number");
|
||||||
|
if(sc.nextInt() == iterator.next()){
|
||||||
|
System.out.println("Yeet");
|
||||||
|
} else {
|
||||||
|
System.out.println("git gud");
|
||||||
|
won = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(won){
|
||||||
|
System.out.println("You win");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package P3;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
|
||||||
|
public static void main( String[] args ) {
|
||||||
|
List<AtomicLongComparable> lngLst = new ArrayList<AtomicLongComparable>();
|
||||||
|
lngLst.add( new AtomicLongComparable() );
|
||||||
|
lngLst.add( new AtomicLongComparable( 99 ) );
|
||||||
|
lngLst.add( new AtomicLongComparable( 42 ) );
|
||||||
|
System.out.println( findeMaximum ( lngLst ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AtomicLong findeMaximum(List<AtomicLongComparable> alc){
|
||||||
|
AtomicLongComparable tmp = alc.get(0);
|
||||||
|
for(AtomicLongComparable num : alc){
|
||||||
|
if(num.compare(tmp)==1){
|
||||||
|
tmp = num;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user