Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
faermanj committed Mar 21, 2024
1 parent 9ad8f77 commit a7436fe
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ RUN bash -c "sudo install-packages mysql-client"
USER gitpod
RUN bash -c "brew install hurl"

ARG JAVA_SDK="21.0.2-amzn"
ARG JAVA_SDK="22-graalce"
RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh \
&& sdk install java $JAVA_SDK \
&& sdk default java $JAVA_SDK \
&& sdk install maven
&& sdk install quarkus"

RUN bash -c "curl 'https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip' -o 'awscliv2.zip' && unzip awscliv2.zip && sudo ./aws/install"
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>java-interviews</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<compiler-plugin.version>3.8.3</compiler-plugin.version>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/cloud/caravana/puzzlers/lang/Ints.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package cloud.caravana.puzzlers.lang;

class Ints {
public static void main(String... args){
var a = (Integer) 42;
var b = (Integer) 42;
var i = (Integer) 333;
var j = (Integer) 333;
System.out.println(a == b);
System.out.println(i == j);
}
}
87 changes: 87 additions & 0 deletions src/main/java/cloud/caravana/refactoring/Cards.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package cloud.caravana.refactoring;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

public class Cards {
private List<Card> cards;

public Cards() {
cards = new ArrayList<>();
initializeCards();
}

private void initializeCards() {
String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"};
String[] ranks = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"};

for (String suit : suits) {
for (String rank : ranks) {
cards.add(new Card(rank, suit));
}
}
}

public void shuffle() {
Collections.shuffle(cards);
}

public Card pickFirstCard() {
return cards.get(0);
}



private class Card {
private String rank;
private String suit;

public Card(String rank, String suit) {
this.rank = rank;
this.suit = suit;
}

public String getRank() {
return rank;
}

public void setRank(String rank) {
this.rank = rank;
}

public String getSuit() {
return suit;
}

public void setSuit(String suit) {
this.suit = suit;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Card card = (Card) o;
return rank.equals(card.rank) && suit.equals(card.suit);
}

@Override
public int hashCode() {
return Objects.hash(rank, suit);
}

@Override
public String toString() {
return rank + " of " + suit;
}
}

public static void main(String[] args) {
Cards cards = new Cards();
cards.shuffle();
Card firstCard = cards.pickFirstCard();
System.out.println("First card: " + firstCard);
}
}

0 comments on commit a7436fe

Please sign in to comment.