public class Card {
private String face;
private String suit;
public Card(String cardFace, String cardSuit){
cardFace = face;
cardSuit = suit;
}
public String toString(){
return face + " of " + suit;
}
}
import java.util.Random;
public class DeckOfCards {
private Card deck[];
private int currentCard;
private final int NUMBER_OF_CARDS = 52;
private Random randomNumber;
public DeckOfCards(){
String faces[] = {"ACE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING"};
String suits[] = {"HEARTS", "DIMOND", "SPADES", "CLUBS"};
deck = new Card[NUMBER_OF_CARDS];
currentCard = 0;
randomNumber = new Random();
for(int count = 0; count<deck.length; count++){
deck[ count ] = new Card(faces[ count % 13 ], suits[ count / 13 ]);
}
}
public void shuffle(){
currentCard = 0;
for(int first = 0; first<deck.length; first++){
int second = randomNumber.nextInt(NUMBER_OF_CARDS);
Card temp = deck[first];
deck[first] = deck[second];
deck[second] = temp;
}
}
public Card dealCard(){
if(currentCard < deck.length )
return deck[ currentCard++ ];
else
return null;
}
}
public class DeckOfCardTest {
public static void main(String[] args) {
DeckOfCards myDeckOfCards = new DeckOfCards();
myDeckOfCards.shuffle();
for(int i = 0; i<13; i++ ){
System.out.printf("%-20s%-20s%-20s%-20s\n", myDeckOfCards.dealCard(), myDeckOfCards.dealCard(),myDeckOfCards.dealCard(),myDeckOfCards.dealCard());
}
}
}
public class Card {
private String face;
private String suit;
public Card(String cardFace, String cardSuit){
cardFace = face;
cardSuit = suit;
}
public String toString(){
return face + " of " + suit;
}
}
highlighted
public class BarcodeEAN128 extends Barcode {
//some variables decalration
static {
final Map m = new HashMap();
//some processing
}
}
What is static branch in a class mean? Like below-
Code:public class BarcodeEAN128 extends Barcode { //some variables decalration static { final Map m = new HashMap(); //some processing } }
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class triangleFormation {
public static boolean isTriangle (int a, int b, int c){
if (c>a+b || a>b+c || b>a+c ){
return false;
} else{
return true;
}
}
public static void main (String [] args)throws IOException {
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in));
String s = bufferedreader.readLine();
String r = bufferedreader.readLine();
String t = bufferedreader.readLine();
int m = Integer.parseInt(s);
int n = Integer.parseInt(r);
int o = Integer.parseInt(t);
System.out.println("the triangle is " + isTriangle (m,n,o));
}
}