Blackjack Codingbat Solution
One direction where we can take our programming skills is game development. Here, we'll build a text based Blackjack engine that allows us to play against a dealer, who follows conventional house rules. The logic of blackjack is simple, but is sufficiently complex that we can gain valuable experience for making more complicated games later on. As we said, this engine has several. The Logic-2 section of CodingBat contains just nine exercises. Yet, there are slightly more challenging than any of the pervious exercises, which means that you may have to spend more time on them, compared to, say, String-1. “makeBricks” is a favorite of mine, not just because some of the solutions floating around on the Internet are nothing but comical. If you've ever tried to teach yourself programming and couldn't quite get going, then these assignments are for you. Refined over fifteen years, these are the assignments I have used to teach the basics of Java to nearly 2,000 ordinary public school students over my career. As part of a recent interview, I was assigned to write a small BlackJack program. After submitting the solution, I received an answer that 'the solution was functionally OK, but was way below their standards of quality code, especially coming from a person with significant experience' (I have 15 years experience).
N | Date | Topic | File/Worksheets | Due Date | Drop Off Folder | Notes to read / Homework |
1 | 5/09 | Inroduction. Gr 11 review | Java Review Cheat Sheet | 9.09 | 01_DMOJ | Read Java Review Cheat Sheet Section 1 - 19 DMOJ.ca questions Question 1: CCC '12 J2 - Sounds fishy! Question 2: CCCHK '08 J2 - Lucky Number |
2 | 9/09 | Gr 11 review | 13.09 | 01_DMOJ | Read Java Review Cheat Sheet Section 21-26 DMOJ.ca questions Solve 3.5 questions: Victoria Park Programming Contest for Beginners | |
3 | 11/09 | Pseudocode. JETS. Flow charts.Sorting algoriths. | pseudocode-in-exams.pdf Approved_Pseudocode_Notation_Sheet.pdf JETS.pdf | Homework: Textbook. Chapter 4. pp.174-183. ICS4U_Arrays_SortingExercise_2019.doc | ||
4,5,6 | 23-19/09 | Pseudocode. Flow charts. Review Java Grade 11. | DynamicArrays_ArrayLists.doc | Homework: Textbook. Chapter 4. All pages. | ||
7 | 23/09 | Array Lists. Collections. Pseudocode. Big O notation. | ICS4U_Chapter4_Highlights.docx | Homework: Textbook. Chapter 4. pp.174-183. Homework23_09.docx | ||
8 | 25/09 | Pseudocode. | 2D_array_GanttChart_IB_ICS4U.docx | Homework: Textbook. Chapter 4. All. Homework_PseudoCodePractice_25_09.docx | ||
9 | 27/09 | Review OOP | OOP_01_Objects_Constructors.doc OOP_02_UML_Encapsulation.doc OOP_03_Overloading_static_toString.doc OOP_04_Inheritance.doc OOP_05_Static_Methods_Examples.doc OOP_06_definitions_Polymorphism.doc | Homework: Textbook. Chapter D2. pp.312-318. | ||
10 | 1/10 | Test 1 Part A (club fair) | Homework: Textbook. 312-318. | |||
11 | 3/10 | Test 1 Part B | ||||
12 | 7/10 | UML diagrams, Inheritance, Aggregation, and Dependency | UML diagrams_practice.docx | Homework: UML diagrams_practice.docx Text book: 294-308 | ||
13 | 9/10 | GUI review | A folder GUI/Layouts is posted in the pickUp area | Homework: Create a JFrame and 2 JPanels. One panel should be intro/menu pannel; second panel should have GUI components. Use Layouts to place JTextFields, JButtons, JLabels, and so on. | ||
13 | 15/10 | Actions: Action Listeners, Mouse Listeners, Key Listeners | Homework:Add actions(button click, mouse listener, key listener, and so on) to your Frames/Panels. Make sure you have several GUI components - frames should look like your IA project. | |||
14-19 | Oct 17, 21, 23, 25, 29, 31 | Test analysis, GUI Project | GUI_Project_2020.docx | Homework:GUI project | ||
21 | Nov 5 | GUI Project analysis, Databases | Databases for beginners.pdf | Homework:Databases. COntinue to work on IA project | ||
22 | 7/11 | JTable, OO test practice | Example PhilosophersJTable.java in the pick up folder JTable_expanation_example.pdf | Homework:Homework_practicePaper2.pdf Homework_practicePaper2_2.pdf | ||
23 | 11/11 | Databases, ODBC drivers | DatabaseWithJTable.java in the pick up folder DatabasesSQL.pdf SQLITE_driver_ECLIPSE.docx | Homework: Create a dabase. Access it from Java application. Prepare for the test 2 OOP. | ||
24 | 13/11 | Test 2 OOP | ||||
15/11 | PA day | |||||
25 | 19/11 | System Fundamentals 1.1.1-1.1.7 | 1_1_1_7_SystemFundamentals.pptx - pick up folder Topic 1 Systems in organisationsNotes.docx - pick up folder | Homework: Textbook: pages 1-12 Online quiz Video on youtube (all or from 10.23 to 26:40 ) | ||
26 | 21/11 | System Fundamentals 1.1.8-1.1.14; 1.2.1 | 1_8_1_14.pptx - pick up folder Topic 1 Systems in organisationsNotes.docx - continue pick up folder | Homework: Textbook: pages 13-23 Online quiz System Fundamentals - Part 3 the rest System Fundamentals - Part 4 System Fundamentals - Part 1 System Fundamentals - Part 2 | ||
27 | 25/11 | Quiz 1. Test 2 Analysis. | TestAnalysis_OOP_test2.pptx - pick up folder | Homework: Textbook: review pages 1-41 Youtube videos listed for the previous class(21/11). | ||
28 | 27/11 | System Fundamentals 1.2.1 - 1.2.8 Was coverd on November 23rd. insteaf of 1.1.8-1.1.14 System Fundamentals 1.2.9 - 1.2.16 | 1_2_1_1_2_8.pptx - pick up folder 1_2_9_1_2_16.pptx - pick up folder | Homework: Textbook: pages 41-57 Youtube videos listed for the previous class(21/11). | ||
29 | 29/11 | Computer Organization 2.1.1-2.1.3 | 2_1_1__2_1_3.pptx - pick up folder | Homework: Textbook: pages 61-68 Computer Organization - Part 1 Computer Organization - Part 2 | ||
30 | 3/12 | Computer Organization 2.1.4-2.1.10 | 2_1_4__2_1_10.pptx - pick up folder | Homework: Textbook: pages 68-102 Computer Organization - Part 1 Computer Organization - Part 2 | ||
31 | 5/12 | Network 3.1.1-3.1.4 | 3_1_1_3_1_4.pptx - pick up folder | Homework: Textbook: pages 124-145 Networks - Part 1 Networks - Part 2 | ||
32 | 9/12 | Network 3.1.5-3.1.11 | 3_1_5_3_1_11.pptx - pick up folder | Homework: Textbook: pages 148-155 Networks - Part 3 | ||
33,34,35 | 13,17,19 /12 | Computer Organization 2.1.9-2.1.14. Binary numbers, Logic Gates, Truth Tables, Logic Equations | Booklet | Homework: Textbook: pages 86-123 Booklet: pages 1-48 | ||
36 | 7/01 | Network 3.1.9-3.1.10, 3.1.12-3.1.17(on your own) | 3_1_9__3_1_16___4_2_8.pptx - pick up folder | Homework: Textbook: pages 152-171 | ||
37 | 9/01 | Quiz on Topic 3 - Networks; Stacks and Queues | 5_1_4__5_1_8.pptx - pick up folder | Homework: HL Textbook: pages 7-22, and 44-45. Homework I: Programming problem to submit: bracket balancing using stacks.To Submit: Java code and pseudocode Balancing brackets_HomeworkResources.docx Homework II: infix <--> prefix<--> postfix. Handout distributed in class. Additional examples and explanations are here: InfixPostFix_Handout_withHomework.docx and solutions PostFixPreFix_Examples.docx | ||
39 | 13/01 | Recursion. | Homework: I. HL Textbook: pages 5-6, Handout 'Recursion 1' in the pick up folder II: Write a java code Codingbat.com website. any 3 from Recursion 1 section, any 3 from Recursion 2 section. https://codingbat.com/java | |||
40 | 15/01 | Recursion 2. Recursion and Graphics. | In the pick up folder: Recursion 2.doc | Homework: Programs: Tree. Tower of Hanoi - at the end of 'Recursion 2' document. | ||
41 | 17/01 | Recursion for IA. Traicing practice. Merge sort. | In the pick up folder: SimpleRecursionTraicingPractice.docx MergeSort.ppt | Homework: Programs: Write merge sort program. Pass an array populated with random numbers, sort if with merge sort and display. | ||
42 | 21/01 | No Test. Stay home and study. | ||||
43 | 29/01 | Marks review day. Word scrambler with recursion | Homework: Write word scrambler program. Use recursion. You can try it on DMOJ.ca https://dmoj.ca/problem/dwite09c1p2 or https://dmoj.ca/problem/ics4p1 | |||
43 | 31/01 | Linked Lists. Doubly Linked Lists. Trees. | 5_1_12_5_1_15.pptx | Homework: textbook pp.23-29- review Queues and Stacks textbook pp.30-38 | ||
44 | 3/02 | Binary Trees. Bianry Search Trees. | 5_1_16__5_1_17.pptx | Homework: textbook pp.39- 55 | ||
45 | 5/02 | BST implementation. ADT: advantages/disadvantages. Chapter 5 review. | 5_1_18__5_1_20.pptx | Homework: textbook - End of chapter examples pp.56- 66 Update BST we created in class. Add 1) removing a node which has a particular data( search for the node first). 2) find minimum vlaue of the tree | ||
46 | 7/02 | Catch Up day. IA | ||||
47 | 11/02 | Test Topic 4 and 5 | ||||
48 | Feb.13 | Topic 6 and Topic 7. | 6_1_1__6_1_3.pptx 6_1_4__6_1_8.pptx 7_1_1__7_1_8.pptx | Power-point files are in the pick-up folder. | ||
49 | Feb.19 | Topic 7 Cont. Case study | case_study_2020.pdf | Power-point files are in the pick-up folder. Read 2020 case study. Pick one term from the list of terms of the 2020 case study. Submit the definition and explain it to the class. |
2018-2019 year
1-7 | 6, 10, 12, 14, 18, 20, 24/09 | Inroduction. Gr 11 review | Java Review Cheat Sheet | |
8 | 26/09 | Test 1 | ||
9 | 28/09 | Pseudocode. JETS. Flow charts. | pseudocode-in-exams.pdf Approved_Pseudocode_Notation_Sheet.pdf JETS.pdf | Homework: Textbook. Chapter 4. pp.174-195. |
10 | 2/10 | Sorting algoriths.Flow charts | SortingAlgorithms.docx | Methods_ArrayTraicingPractice.docx Homework: Textbook. Chapter 4. pp.196-230. |
11 | 4/10 | Review OOP 1 | CardMethods.txt | Homework: (Same as last class)Methods_ArrayTraicingPractice.docx (Same as last class)Textbook. Chapter 4. pp.196-230. (new)Start working on Black Jack Assignment |
12 | 10/10 | Review OOP 2 | OOP_01_Objects_Constructors.doc OOP_02_UML_Encapsulation.doc OOP_03_Overloading_static_toString.doc OOP_04_Inheritance.doc OOP_05_Static_Methods_Examples.doc OOP_06_definitions_Polymorphism.doc | Homework: Textbook. Chapter D2. pp.312-318. Continue working on Black Jack Assignment |
13 | 12/10 | Collections | CollectionPseudocode_Practice.docx | Homework: Textbook. pp.218-219 and 256-289. PseudoCode Homework Practice |
14 | 16/10 | Black Jack Project | Black JackProject.doc | Homework: Create at least 2 classes for the BlackJack project |
15 | 18/10 | UML diagrams, Inheritance, Aggregation, and Dependency | UML diagrams_practice.docx | Homework: Continue working on BlackJack project Finish IA Part A: Planning. Due on October 22!!!! Text book: 291-312 |
16 | 22/10 | IA Part A: Planning due. Work Period. Black Jack Project. | IA_Assessment_criteria.doc A Planning_Sequence_and_CheckMarks.docx Check next tab Gr12 IB Demo for word count and format guidelines.(table on the buttom of the page) | Homework: Continue working on BlackJack project Text book: 291-316 |
17 | 24/10 | GUI review | 2 folders(02_Layouts, 03_MoreLayouts) and a file(01_GUI 1.doc) are posted in the pickUp area | Homework: Create a Frame/Pannel similar to your IA |
18 | 26/10 | GUI events | Test is moved to October 30 due to Robotics trip | Homework: Finish Black Jack which is due October 30st Add a Button click event to your GUI exercise |
19 | 30/10 | Events: Mouse listeners | Homework: Continue working on your GUI project | |
20 | 2/11 | OOP Test | Homework: Continue working on your IA (GUI part) | |
21 | 6/11 | BlackJack analysis | Homework: Continue working on your IA (GUI part) | |
22 | 8/11 | Test 2 back. Events: Keyboard Listener | Homework: Continue working on your IA (GUI part) Link to ComboBox examples ( for Talia) Link to example on how to add ImageIcon to a label ( for Manasha) | |
23-24 | 12,14/11 | Databases | Homework: Continue working on your IA (GUI part + database part) | |
25 | 20/11 | System Fundamentals 1.1.1-1.1.7 | 1_1_1_7_SystemFundamentals.pptx - pick up folder Topic 1 Systems in organisationsNotes.docx - pick up folder | Homework: Textbook: pages 1-12 Online quiz Video on youtube (all or from 10.23 to 26:40 ) |
26 | 22/11 | System Fundamentals 1.1.8-1.1.14; 1.2.1 | 1_8_1_14.pptx - pick up folder Topic 1 Systems in organisationsNotes.docx - continue pick up folder | Homework: Textbook: pages 13-23 Online quiz System Fundamentals - Part 3 the rest System Fundamentals - Part 4 System Fundamentals - Part 1 System Fundamentals - Part 2 |
28 | 26/11 | System Fundamentals 1.2.1 - 1.2.8 Was coverd on November 23rd. insteaf of 1.1.8-1.1.14 System Fundamentals 1.2.9 - 1.2.16 | 1_2_1_1_2_8.pptx - pick up folder 1_2_9_1_2_16.pptx - pick up folder | Homework: Textbook: pages 41-57 Youtube videos listed for the previous class(22/11). |
29 | 30/11 | Computer Organization 2.1.1-2.1.3 | 2_1_1__2_1_3.pptx - pick up folder | Homework: Textbook: pages 61-68 Computer Organization - Part 1 Computer Organization - Part 2 |
30 | 3/12 | Computer Organization 2.1.4-2.1.10 | 2_1_4__2_1_10.pptx - pick up folder | Homework: Textbook: pages 68-102 Computer Organization - Part 1 Computer Organization - Part 2 |
31,32,33 | 6,10,12 /12 | Computer Organization 2.1.9-2.1.14. Binary numbers, Logic Gates, Truth Tables, Logic Equations | Booklet | Homework: Textbook: pages 86-123 Booklet: pages 1-48 |
34 | 14/12 | Network 3.1.1-3.1.4 | 3_1_1_3_1_4.pptx - pick up folder | Homework: Textbook: pages 124-145 Networks - Part 1 Networks - Part 2 |
35 | 18/12 | Network 3.1.5-3.1.11 | 3_1_5_3_1_11.pptx - pick up folder | Homework: Textbook: pages 148-155 Networks - Part 3 |
36 | 20/12 | Network 3.1.9-3.1.10, 3.1.12-3.1.17 | 3_1_9__3_1_16___4_2_8.pptx - pick up folder | Homework: Textbook: pages 152-171 |
37 | 8/01 | Quiz on Topic 3 - Networks; Stacks and Queues | 5_1_4__5_1_8.pptx - pick up folder | Homework: HL Textbook: pages 7-22, and 44-45. Homework I: Programming problem to submit: bracket balancing using stacks.To Submit: Java code and pseudocode Balancing brackets_HomeworkResources.docx Homework II: infix <--> prefix<--> postfix. Handout distributed in class. Additional examples and explanations are here: InfixPostFix_Handout_withHomework.docx and solutions PostFixPreFix_Examples.docx |
38 | 10/01 | Stacks and Queues implementation. Evaluation of postfix expressions | Homework: I. HL Textbook: pages 23-29, II: Write a java code to evaluate postfix expression. You can update my program that converts in-fix into post-fix (in the InfixPostFix_Handout.doc) by adding evaluation method. III. 2D array practice 2D_arrayPractice_Homework.docx | |
39 | 14/01 | Recursion. | Homework: I. HL Textbook: pages 5-6, Handout 'Recursion 1' in the pick up folder II: Write a java code Codingbat.com website. any 4 from Recursion 1 section, any 2 from Recursion 2 section. https://codingbat.com/java | |
40 | 16/01 | Recursion 2. Recursion and Graphics. | In the pick up folder: Recursion 2.doc PracticeQuestion_RecursionInClass.doc | Homework: Programs: Tree. Tower of Hanoi. |
41 | 18/01 | Linked List. Review for the test. Short day. | Homework: Programs: Tree. Tower of Hanoi. | |
42 | 22/01 | Test. Recursion. Stacks. Queues. | ||
43 | 4/02 | Linked Lists (Cont..) Doubly Linked Lists. Trees. | ||
43 | 4/02 | Linked Lists (Cont..) Doubly Linked Lists. Trees. | 5_1_12_5_1_15.pptx | |
44 | 6/02 | Binary Trees. Bianry Search Trees. | 5_1_16__5_1_17.pptx | |
44 | 8/02 | BST implementation. ADT: advantages/disadvantages. | Update BST we created in class. Add removing a node which has a particular data( search for the node first). | |
45-49 | Feb.12,14, 18,20, and 22 | Topic 6 and Topic 7. | Power-point files are in the pick-up folder. | |
50 | 26/02 | Controls System. Case study. | Read CaseStudy2019.pdf Prepare explanation/definition of one of the terms for case study. | |
51 | 28/02 | Case study: Definitions. | Prepare one question for the case study discussion. | |
52 | 4/02 | Case study: Defintions. Alghorithms. | Learn about load balancing algoriths. Find information about 'source IP hash'. Read and analyze the article “London Ambulance CAD failure” https://erichmusick.com/writings/technology/1992-london-ambulance-cad-failure.html |
Logic-2
Codingbat Blackjack Solution
CODING BAT ANSWERS IS MOVING TO A NEW AND IMPROVED SITE, PLEASE CLICK HERE TO VIEW SOLUTIONS TO EVERY JAVABAT PROBLEM AND LEARN FROM MY MISTAKES!!!!
Questions covered in this section include: makeBricks, loneSum, luckySum, noTeenSum, roundSum, closeFar, blackjack, evenlySpaced, and makeChocolate.
makeBricks
loneSum
luckySum
noTeenSum
roundSum
closeFar
blackjack
evenlySpaced
Blackjack Codingbat Solutions
makeChocolate
Questions covered in this section include: makeBricks, loneSum, luckySum, noTeenSum, roundSum, closeFar, blackjack, evenlySpaced, and makeChocolate.