id
stringlengths
36
36
text
stringlengths
1
1.25M
7c79e2f4-b23e-4acb-b45c-c157ebd3cec7
public static void playAgain() { System.out.println("\n>Do you wan to play again?(y/n)"); String answer = stringInput.nextLine(); answer.toLowerCase(); try { if (answer.equals("y")) { dealer.handEndReset(); play(); } else { System.out.println("Thanks for playing. Your total: " + player.getBank()); } } catch (IllegalStateException e) { e.printStackTrace(); } }
cf148f2c-f0e6-4c7b-96b6-691ac109d40a
public Hand(Card a, Card b) { Hand.add(a); Ranks.add(a.getRank()); Values.add(a.getValue()); handValue += a.getValue(); Hand.add(b); Ranks.add(b.getRank()); Values.add(b.getValue()); handValue += b.getValue(); }
fb27784c-b85a-42e8-a22d-1fa65f3465ff
public void addCard(Card c) { Hand.add(c); handValue += c.getValue(); Ranks.add(c.getRank()); Values.add(c.getValue()); }
f4699d1c-f6b2-4101-8dbf-6148755e2dc9
public int getHandValue() { return handValue; }
9ee463b8-a4ca-4469-b297-ceffbd957fc5
public void clearHand() { Hand.clear(); handValue = 0; Ranks.clear(); Values.clear(); }
04352631-7be6-43d1-9df9-20b163eac1b1
public void handBust(){ handValue = 0; }
c6c970aa-76b3-4a70-8b65-7cde7478e9a8
public void setAceValue(){ Values.remove(Values.indexOf(11)); Ranks.remove(Ranks.indexOf("Ace")); handValue -= 10; }
358ac1c6-6dcf-4a5f-bb23-87748601add4
public ArrayList<Card> getHand() { return Hand; }
3eae6b88-6f0c-422a-acc9-8e7f07c5c8b7
public ArrayList<Integer> getHValues(){ return Values; }
8f434604-2434-4227-922f-7d151e7ae903
public ArrayList<String> getHandRanks() { return Ranks; }
13ac1a4f-252d-400a-bdea-4d42f2b29fbe
public String toString() { return Hand.toString(); }
5c5c6f16-4480-41df-acfa-f5fac05b14c7
public static void main(String[] args) { Card a = new Card(4, 3); Card b = new Card(12, 3); Card c = new Card(1, 1); Hand h = new Hand(a, b); h.addCard(c); System.out.println(h.getHand().toString()); h.clearHand(); System.out.println(h.getHand().toString()); }
75259bf8-4cf3-41b6-99a7-7e96ffeb33c9
public static void main(String[] args) { Shoe shoe = new Shoe(4); //Iterates through all of the cards in Shoe and prints its value for (int i = 0; i < shoe.getShoe().size(); i++) { for (Card c : shoe.getShoe()) { System.out.println(c.toString()); } } System.out.println("TESTING: Dealing a card and printing the value: "); System.out.println(shoe.dealCard().toString()); }
eaf91108-52e2-406a-84e0-21b54ab58eed
public Card(int r, int s) { rankNumber = r; //Construction assigns r to rankNumber suitNumber = s; //Construction assigns s to suitNumber //Switch statement takes the integer values that are passes into the //Constructor and assigns String to those integer values switch (rankNumber) { case 0: rank = null; value = 0; break; case 1: rank = "Ace"; value = 11; break; case 2: rank = "Two"; value = rankNumber; break; case 3: rank = "Three"; value = rankNumber; break; case 4: rank = "Four"; value = rankNumber; break; case 5: rank = "Five"; value = rankNumber; break; case 6: rank = "Six"; value = rankNumber; break; case 7: rank = "Seven"; value = rankNumber; break; case 8: rank = "Eight"; value = rankNumber; break; case 9: rank = "Nine"; value = rankNumber; break; case 10: rank = "Ten"; value = rankNumber; break; case 11: rank = "Jack"; value = 10; break; case 12: rank = "Queen"; value = 10; break; case 13: rank = "King"; value = 10; break; default: throw new IllegalStateException("Invalid Card Rank"); } switch (suitNumber) { case 0: suit = null; break; case 1: suit = "Hearts"; break; case 2: suit = "Spades"; break; case 3: suit = "Clubs"; break; case 4: suit = "Diamonds"; break; default: throw new IllegalStateException("Invalid Card Suit"); } }
9e2d0c35-b387-445d-a5a5-6e085db950c8
public String getRank() { return rank; }
60e50111-e645-42eb-8377-49626f56ed87
public int getValue() { return value; }
17bfcbba-50c0-4b3f-98ac-1bc4d874733e
public void setAce() { System.out.println(this.toString() + " changes to 1"); rank = "Ace (1)"; value = 1; }
42d16e81-cd4c-4b8b-b7f0-89d5fa202b12
public String getSuit() { return suit; }
f2d2db0f-a034-44ae-9254-c099a1c4eb7c
public String toString() { return this.getRank() + " of " + this.getSuit(); }
c1c59e27-d489-4cb1-9455-8e7e385732d3
public static void main(String[] args) { Shoe shoe = new Shoe(4); Hand handp1 = new Hand(shoe.dealCard(), shoe.dealCard()); Hand handp2 = new Hand(shoe.dealCard(), shoe.dealCard()); Hand handp3 = new Hand(shoe.dealCard(), shoe.dealCard()); Player player1 = new Player(handp1, "Jake", 435.0); System.out.println(player1.toString()); System.out.println("Testing playerBet() - Betting $35"); player1.playerBet(35.0); System.out.println(player1.toString()); System.out.println("Testing insurance() - Player can purchase insurance"); player1.insurance(); System.out.println(player1.toString()); System.out.println("Testing getHand()"); System.out.println(player1.getHand()); System.out.println("Testing getBank()"); System.out.println(player1.getBank()); System.out.println("Testing getBet()"); System.out.println(player1.getBet()); System.out.println("Testing getBankString()"); System.out.println(player1.getBankString()); System.out.println("Testing getHandArray() and toString() of Hand.java"); System.out.println(player1.getHandArray().toString()); Player player2 = new Player(handp2, "Bob", 10.0); System.out.println("Testing blackJack() with $10"); player2.playerBet(10.0); player2.blackJack(); System.out.println("Player wins - can lead to BlackJack"); player2.wonBet(); System.out.println(player1.toString()); System.out.println("player hits"); player2.hit(shoe.dealCard()); System.out.println(player1.toString()); System.out.println("Testing blackJack()"); player2.blackJack(); System.out.println(player1.toString()); System.out.println("Testing playerLost()"); player2.playerLost(); System.out.println(player1.toString()); System.out.println("Testing playerBust()"); player2.playerBust(); System.out.println(player2.toString()); }
69d3a036-8dc0-451d-ae51-6385d0d7d778
public Shoe(int numDecks) { this.deckCount = numDecks; this.numCards = deckCount * numDecks; if (numDecks >= minDecks) { for (int i = 1; i < 14; i++) { for (int j = 1; j < 4; j++) { Shoe.add(new Card(i, j)); } } } else { throw new IllegalStateException("Minimum decks is 4"); } Collections.shuffle(Shoe); }
6b97672b-4d48-49ad-9fde-2420734d2d9c
public void shuffle() { Collections.shuffle(Shoe); }
290c8fd8-9c2e-4231-a2b7-f27dfce39bc9
public Card dealCard() { numCards = deckCount * 52; if (dealt >= numCards) { throw new IllegalStateException("No Cards Left In The Deck"); } else { cardsRemaining = numCards - dealt; switch (cardsRemaining) { case 15: System.out.println("15 cards remaining in the shoe"); break; case 5: System.out .println("5 cards remaining in the shoe, adding cards " + "to shoe "); Shoe.clear(); for (int h = 0; h < deckCount; h++) { for (int i = 1; i < 14; i++) { for (int j = 1; j < 4; j++) { Shoe.add(new Card(i, j)); Collections.shuffle(Shoe); } } } break; } dealt++; return Shoe.get(dealt - 1); } }
1dc61c61-8e5a-448f-82b1-dd9f6a3cb684
public ArrayList<Card> getShoe() { return Shoe; }
d0d41953-add3-4780-b14f-f245b162863c
public Item(){}
ec044fd3-8f32-4111-ae63-0026f58b46a1
public void imprimir(){ //imprimir todas as coisas }
93c29433-dac4-4bb1-a885-78298db4d928
public Livro(String editora,int preco,int ano,String nome,int codigo,String autor){ this.codigo = codigo; this.preco = preco; this.ano = ano; this.nome = nome; this.editora = editora; this.autor = autor; }
7172d856-4b9f-4071-8cc3-ceaf0e69cdaa
public void imprimir(){ //imprimir todas as coisas }
e9757231-47f4-48a7-9649-e78488087c72
public Revista(String nome,int cod,int preco,String editora,int mes,int ano){ this.nome=nome; this.codigo=cod; this.preco=preco; this.editora=editora; this.mes=mes; this.ano=ano; }
e1591489-4fb0-4efe-a90f-fc41c7f8108a
public void alta(int qtde){ Item x; for(int i = 1;i<=qtde;i++){ x = new Item(); this.listaDeitem.add(x); } }
995bd307-84e9-4191-a976-736af05be6f1
public void baixaEstoque(int qtde){ for(int i = 1;i<=qtde;i++){ listaDeitem.remove(0); } }
0178d2b8-f39d-4a05-8b56-351cc19dc370
public boolean verifica_estoque(int qtde){ boolean teste; teste = this.listaDeitem.size()>=qtde; return teste; }
ae935841-7f9a-4b79-96ab-fd7f7eb3b33b
public String getNome(){ return this.nome; }
b6663326-be66-4d68-b621-8999f9370ac1
public void imprimir(){ //impressão cód e preço System.out.print(this.codigo); System.out.print(" "); System.out.println(this.preco); }
0c2fc74e-f2bd-4f35-9083-bc26a470a866
public DescritorProduto(){ }
01863c18-20f9-44d5-88f9-6e520cd492c3
public DescritorProduto(int cod, int preco){ this.codigo = cod; this.preco = preco; this.listaDeitem = new ArrayList(); }
ebd4b740-bb12-421b-a135-fde02d769f69
public int getCodigo() { return this.codigo; }
8a55b0ea-ace8-4956-9735-b396685b9fec
public int getPreco(){ return this.preco; }
ba93d9cb-6dd0-4cf2-a75c-52a56571534f
public void insere_produto(int cod,int qtde,Livraria livraria) { Livraria l; DescritorProduto p; l = livraria; p = l.descritor(cod); if(p==null){ //mensagem de erro } else { this.v.addItem(p,qtde); } }
a8ed0bed-29b9-4090-b5cb-29577b325718
public void finaliza_venda(Livraria livraria){ if(!livraria.existeRelatorio(Starter.semana)){ livraria.novo_relatorio(); } this.v.fecha_conta(); }
7229ce74-f107-4f8d-aea1-6e7bf0847c71
public void alta_estoque(int cod,int qtde, Livraria livraria){ livraria.alta(cod, qtde); }
5a6fa966-cc11-41d7-9ae4-7125fe4ec755
public void relatorio_semanal(long semana, Livraria livraria){ livraria.apresentaRelatorio(semana); }
cc7c60ac-6100-4460-834c-91babef2d3ae
public void confirmar_impressao(boolean conf,Livraria livraria){ if(conf) livraria.apresentaRelatorio(Starter.semana); }
f27865b0-7323-43a8-bf30-a7fbc5537b09
public void confirmar_pagamento(Livraria livraria){ this.v.pagamento_validado(); livraria.addRelatorio(v); }
e86baa2f-9290-4a13-b7ff-ff90cc1bd21e
public boolean verifica_senha(String senha){ if(this.senha == senha){ return true; } return false; }
68c20d3b-887c-4498-85db-e65dcfd8f6e4
public void inicia_venda(){ this.v = new Venda(); }
ec6ca625-7297-4f17-b2b8-d541a5ab7f90
public Venda pegaVenda(){ return this.v; }
805c6956-6296-4f33-9ca1-40026c2b930e
public String getNome(){ return this.nome; }
7ed0b063-4cc4-416b-b4f8-6271fdcee470
public Funcionario(String nome,String login,String senha){ this.nome = nome; this.login = login; this.senha = senha; }
c7707478-ada0-4cfd-87db-3c9458fe8879
public String getSenha() { return this.senha; }
1af98dee-9955-49ca-9360-3cd44069d1f3
public String getLogin() { // TODO Auto-generated method stub return this.login; }
966cc425-a1ed-4825-ad91-077f74c1d49b
public void criar_livro(String nome,int cod,int preco,String autor,int ano,String editora,Livraria livraria){ }
08cc8b07-2ede-439e-852c-379ac80b503e
public void criar_revista(String nome,int cod,int preco,String editora,int mes,int ano, Livraria livraria){ }
1f5f4cca-30a3-4f58-b28c-529d6cdfdf66
public void criar_caderno(int codigo,int preco, Livraria livraria){ }
9bcf9389-fd29-4d14-9931-93cea726183b
public void remover_produto(int cod, Livraria livraria){ }
cf20644c-b89c-42ed-9d2f-d6774df4658a
public Administrador(String nome, String login, String senha) { super(nome, login, senha); // TODO Auto-generated constructor stub }
782a1456-ac30-4414-8476-feeba951cc5f
public void criar_livro(String nome,int cod,int preco,String autor,int ano,String editora,Livraria livraria){ livraria.novo_livro(nome, cod, preco, autor, ano, editora); }
3f5a357c-878d-4ab0-a788-8a6770e1ad59
public void criar_revista(String nome,int cod,int preco,String editora,int mes,int ano,Livraria livraria){ livraria.nova_revista(nome, cod, preco, mes, ano, editora); }
8cf021ce-8130-4226-b18a-a93dd36da00e
public void criar_caderno(int codigo,int preco,Livraria livraria){ livraria.novo_caderno(codigo, preco); }
1316435c-59f8-4e13-b881-de9393189c46
public void remover_produto(int cod){ Livraria l; l = Starter.prog.global.getLivraria(); l.remover(cod); }
c667cd8f-a173-4f20-b23d-2cf5b3dff2e8
public int fecha_conta(){ return this.p.getPreco()*this.quantidade; }
5b995209-1ba5-4726-8efa-8cb3c59156fe
public void elimina(){ this.p.baixaEstoque(this.quantidade); }
6f74f9dc-7fb3-4c5b-8973-2d08de515024
public int codigo(){ return p.getCodigo(); }
82e6b645-9f49-454c-be16-d043ec255ff0
public int getQtde(){ return this.quantidade; }
f777c0c3-b942-4ce6-93ca-2347f6e40f2c
public ProdutoVendido(DescritorProduto d, int qtde){ boolean teste; this.p = d; teste = d.verifica_estoque(qtde); if(teste){ this.quantidade = qtde; } else{ this.quantidade = -1; //mensagem de erro; } }
b86e224a-0f11-4193-801c-ecaabed9253e
public int getCod(){ return this.cod; }
25c6becf-a09e-4161-80f8-76ace47c2611
public void aumentaQtde(int qtde){ this.qtde+=qtde; }
4c7f02b8-8ca5-4bd0-b043-bd003594d6b9
public int getQtde(){ return this.qtde; }
e1eb3769-dc12-4864-a849-9a12161173e2
public TopVendidos(int cod,int qtde){ this.cod = cod; this.qtde = qtde; }
9ce484ad-11fb-4cfb-a451-5834336660ad
public void add(Venda venda){ this.listaDeVendas.add(venda); }
cce202e0-1663-436d-bb91-9db04d627628
public long getSemana(){ return this.semana; }
3ccc9928-58d5-4446-bb53-047940f4c3df
public void setSemana(){ }
01ef300f-560d-4dad-9e50-c6a9c32ea0d9
public void apresentar(Livraria livraria){ int acumulado = 0; int max; List<TopVendidos> listaTop = null; List<TopVendidos> listaTopGeral = null; boolean contem; for(Venda v:this.listaDeVendas) { acumulado += v.total_geral(); for(ProdutoVendido p:v.getProdutos()) { if(listaTop==null){ listaTop.add(new TopVendidos(p.codigo(),p.getQtde())); } else { contem = false; for(TopVendidos tp:listaTop) { if(tp.getCod()==p.codigo()) { tp.aumentaQtde(p.getQtde()); contem = true; } } if(!contem) { listaTop.add(new TopVendidos(p.codigo(),p.getQtde())); } } } } while(!listaTop.isEmpty()) { max = 0; for(TopVendidos tp:listaTop) { if(tp.getQtde()>max) { max=tp.getQtde(); } } for(TopVendidos tp:listaTop) { if(tp.getQtde()==max){ listaTopGeral.add(tp); listaTop.remove(tp); } } } for(int i = 0; i<=4;i++){ livraria.descritor(listaTopGeral.get(i).getCod()).imprimir(); } }
1130f777-c0a7-4a87-9f97-8dceda53169d
public void imprimir(){ System.out.println(this.toString()); }
229ab171-da6a-4190-8d15-f4aabf7907f7
public Relatorio(long semana){ this.semana = semana; }
ecee57f5-d297-4e56-866e-3ddd4364accb
public List<ProdutoVendido> getProdutos(){ return this.produtosVendidos; }
92e703ef-fb9d-4d5f-83c4-390445cc8b32
public void fecha_conta(){ int acumulado = 0; for(ProdutoVendido p:this.produtosVendidos) { acumulado += p.fecha_conta(); //imprimir preço por item } System.out.println(acumulado); }
375b71be-ba75-47d6-8ace-ed6aeb952ccd
public void addItem(DescritorProduto d,int qtde){ ProdutoVendido p; p = new ProdutoVendido(d,qtde); if(p.getQtde()>0){ produtosVendidos.add(p); } }
07e51b9b-8637-4cd6-b036-61c19cbfac57
public List<Integer> vendidos(){ List<Integer> aux = null; for(ProdutoVendido p:this.produtosVendidos){ aux.add(p.codigo()); } return null; }
dd561a35-0b1b-4f16-99af-6bda009bd17e
public void pagamento_validado(){ for(ProdutoVendido p:produtosVendidos){ p.elimina(); } }
91e9d160-6f2e-4a2e-8402-0116e70c6601
public int total_geral(){ return 0; }
b8a4356a-2c3d-4cc3-83c3-5ee07d1aff18
public Venda(){ this.validacao_de_pagamento = false; }
5e761567-fae7-461f-a3f6-c4518cab68f8
public Globais(){ setLivraria(new Livraria()); }
4060cc29-2636-4a4d-a23e-9fae74dd2205
public Livraria getLivraria() { return livraria; }
dfd4e604-fd14-43a9-b324-dd3b9d711077
public void setLivraria(Livraria livraria) { this.livraria = livraria; }
9e98268d-e57d-41ce-b7b9-8d33f2bed254
public boolean efetua_login(String nome,String senha, Livraria livraria) { return livraria.entra_login(nome, senha); }
2f77226d-2b6c-4c45-837d-e0f9a7817b50
public Logger() { }
bfa5d0cf-2ae7-4b51-a13d-4e4d9f169222
public static void dados_busca(String nome, Livraria l){ l.busca_nome(nome); }
2144bbc4-53a6-4f9f-930e-13403143ba12
public static DescritorProduto dados_busca(int num, Livraria l){ return l.busca_num(num); }
dfcc0260-092a-4a52-aa51-7f44d2a57849
public Buscador(){}
3661dcfd-379b-42e8-bf1b-0209b711f84e
public void novo_relatorio(){ Relatorio r = new Relatorio(Starter.semana); }
e3dd986b-c3ca-4597-9765-6bed36c0591d
public boolean existeRelatorio(long semana){ for(Relatorio r:this.listaDeRelatorios) { if(r.getSemana()==semana) { return true; } } return false; }
e4cdfd47-609e-4250-8015-33faea3333db
public DescritorProduto descritor(int cod){ for(DescritorProduto d : this.listaDeProdutos){ if(d.getCodigo() == cod){ return d; } } return null; }
821544f8-d276-474b-aaaf-2d6dc1f5b7e5
public void addRelatorio(Venda v){ Relatorio r; r = this.listaDeRelatorios.get(this.listaDeRelatorios.size()); r.add(v); }
d0f35f9c-4669-429b-8848-5786df356400
public void alta(int cod,int qtde){ for(DescritorProduto p:this.listaDeProdutos){ if(p.getCodigo()==cod){ p.alta(qtde); } } }
48fb5979-4c02-44c6-9743-494559837ee5
public void apresentaRelatorio(long semana){ for(Relatorio r:this.listaDeRelatorios){ if(r.getSemana()==semana){ r.apresentar(this); } } }
8536e7b7-bf28-4c77-b7c6-bb706681f1c1
public void novo_livro(String nome,int cod,int preco,String autor,int ano,String editora){ Livro l = new Livro(editora,preco,ano,nome,cod,autor); this.listaDeProdutos.add(l); }
18270a92-3efc-4c83-af73-50d9f7863b1f
public void nova_revista(String nome,int cod,int preco,int mes,int ano,String editora){ Revista r = new Revista(nome,cod,preco,editora,mes,ano); this.listaDeProdutos.add(r); }
97243c5f-0ece-482d-bd48-a14691568230
public void novo_caderno(int cod,int preco){ this.listaDeProdutos.add(new DescritorProduto(cod,preco)); }
4f3f316c-32d5-459c-aba7-2bcb90851e78
public void remover(int cod){ for(DescritorProduto p : this.listaDeProdutos){ if(p.getCodigo()==cod){ this.listaDeProdutos.remove(p); } } }