Skip to content

Instantly share code, notes, and snippets.

View wkdalsgh192's full-sized avatar
🏠
Working from home

Blue_Avocado wkdalsgh192

🏠
Working from home
View GitHub Profile
class Day {
public final static Day MONDAY = new Day();
public final static Day TUESDAY = new Day();
public final static Day WEDNESDAY = new Day();
}
class Month {
public final static Month JANUARY = new Month();
public final static Month FEBRUARY = new Month();
public final static Month MARCH = new Month();
interface Day {
int MONDAY = 1;
int TUESDAY = 2;
int WEDNESDAY = 3;
int THURSDAY = 4;
int FRIDAY = 5;
int SATURDAY = 6;
int SUNDAY = 7;
}
public class EnumExample2 {
private final static int MONDAY = 1;
private final static int TUESDAY = 2;
private final static int WEDNESDAY = 3;
private final static int THURSDAY = 4;
private final static int FRIDAY = 5;
private final static int SATURDAY = 6;
private final static int SUNDAY = 7;
public class EnumExample1 {
public static void main(String[] args) {
/*
* Monday == 1
* Tuesday == 2
* Wednesday == 3
* Thursday == 4
* ...
* Sunday == 7
* */
public class PayGroups {
private List<Pay> pays;
public PayGroups(List<Pay> pays) {
this.pays = pays;
}
public Long getPayPalSum() return getTotalSum(pay -> PayType.isPayPal(pay.getPayType()));
public Long getVisaSum() return getTatalSum(pay -> PayType.isVisa(pay.getPayType()));
public void managingStateAndAction() {
List<Pay> pays = Arrays.asList(
new Pay(PAYPAL, 1000),
new Pay(VISA, 2000),
new Pay(MASTER_CARD, 3000),
new Pay(UNION_CARD, 5000)
);
Long totalSum = pays.stream().filter(pay -> pay.getPayType().equals(VISA)).mapToLong(Pay::getAmount).sum();
public class Orders {
private final List<Order> orders;
public Orders(List<Order> orders) {
this.orders = orders;
}
public long getAmountSum() {
return orders.stream()
.mapToLong(Order::getAmount)
public class LottoTicket {
private static final int LOTTO_NUMBERS_SIZE = 6;
public LottoTicket(List<Long> lottoNumbers) {
List<Long> lottoNumbers = createNonDuplicateNumbers();
validateSize(lottoNumbers);
validateDuplicate(lottoNumbers);
}
public void validateSize(List<Long> lottoNumbers) {
public class LottoService {
private static final int LOTTO_NUMBERS_SIZE = 6;
public void createLottoNumber() {
List<Long> lottoNumbers = createNonDuplicateNumbers();
validateSize(lottoNumbers);
validateDuplicate(lottoNumbers);
}
public void validateSize(List<Long> lottoNumbers) {
public class LottoService {
private static final int LOTTO_NUMBERS_SIZE = 6;
public void createLottoNumber() {
List<Long> lottoNumbers = createNonDuplicateNumbers();
validateSize(lottoNumbers);
validateDuplicate(lottoNumbers);
}
public void validateSize(List<Long> lottoNumbers) {