├── .github
├── ISSUE_TEMPLATE
│ ├── ---bug-report.md
│ └── ---documentation.md
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ └── build.yml
├── .gitignore
├── .project
├── .settings
└── org.eclipse.m2e.core.prefs
├── LICENSE
├── README.md
├── java-core
├── .classpath
├── .factorypath
├── .project
├── .settings
│ ├── org.eclipse.jdt.apt.core.prefs
│ ├── org.eclipse.jdt.core.prefs
│ └── org.eclipse.m2e.core.prefs
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── ai
│ │ └── certifai
│ │ ├── basic
│ │ ├── ex1
│ │ │ ├── HelloWorld.java
│ │ │ ├── HelloWorld.md
│ │ │ └── metadata
│ │ │ │ └── publicClass.jpg
│ │ ├── ex2
│ │ │ ├── PackagingIntro.java
│ │ │ ├── PackagingIntro.md
│ │ │ └── metadata
│ │ │ │ ├── JavaStructure.png
│ │ │ │ ├── JavaStructure_.png
│ │ │ │ ├── groupID_.jpg
│ │ │ │ └── packageName.jpg
│ │ ├── ex3
│ │ │ ├── BluePrint.java
│ │ │ ├── BluePrint.md
│ │ │ └── metadata
│ │ │ │ ├── cloning.gif
│ │ │ │ ├── public.png
│ │ │ │ ├── spaceX.jpg
│ │ │ │ ├── spaceXengine.jpg
│ │ │ │ └── tenor.gif
│ │ ├── ex4
│ │ │ ├── JavaTerminology.md
│ │ │ ├── Run.java
│ │ │ └── metadata
│ │ │ │ ├── commandprompt.PNG
│ │ │ │ ├── environment.png
│ │ │ │ ├── java.jpg
│ │ │ │ ├── javacommand.png
│ │ │ │ ├── javacommanderror.png
│ │ │ │ ├── javaenvironmentpath.png
│ │ │ │ ├── javaterm.jpg
│ │ │ │ ├── javaterm1.jpg
│ │ │ │ ├── jvm.png
│ │ │ │ └── output.jpg
│ │ ├── ex5
│ │ │ ├── If_ElseIf_Else.java
│ │ │ └── If_ElseIf_Else.md
│ │ ├── ex6
│ │ │ ├── DataTypes.java
│ │ │ └── DataTypes.md
│ │ └── ex7
│ │ │ ├── ForLoop.java
│ │ │ ├── ForLoop.md
│ │ │ └── metadata
│ │ │ ├── forLoop.jpg
│ │ │ └── nestedloop.png
│ │ ├── intermediate
│ │ ├── ex10
│ │ │ ├── ExceptionHandling.java
│ │ │ ├── ExceptionHandling.md
│ │ │ └── metadata
│ │ │ │ └── exception.jpg
│ │ ├── ex11
│ │ │ ├── WhileLoop.java
│ │ │ ├── WhileLoop.md
│ │ │ └── metadata
│ │ │ │ ├── 2.jpg
│ │ │ │ ├── Capture.JPG
│ │ │ │ ├── dowhileloop.jpg
│ │ │ │ └── whileloop.jpg
│ │ ├── ex12
│ │ │ ├── MapImp.java
│ │ │ ├── MapImp.md
│ │ │ └── metadata
│ │ │ │ ├── country_code.jpg
│ │ │ │ ├── key-value.jpg
│ │ │ │ ├── key-value2.jpg
│ │ │ │ └── receipt.jpg
│ │ ├── ex13
│ │ │ ├── SubString.java
│ │ │ ├── SubString.md
│ │ │ └── metadata
│ │ │ │ ├── ref.jpg
│ │ │ │ └── substring.JPG
│ │ ├── ex14
│ │ │ ├── AdvancedSubString.java
│ │ │ ├── AdvancedSubString.md
│ │ │ └── metadata
│ │ │ │ └── sample.jpg
│ │ ├── ex15
│ │ │ ├── QuickSortImp.java
│ │ │ ├── QuickSortImp.md
│ │ │ └── metadata
│ │ │ │ └── sort.png
│ │ ├── ex8
│ │ │ ├── OrderedCollection.java
│ │ │ ├── OrderedCollection.md
│ │ │ └── metadata
│ │ │ │ ├── array.JPG
│ │ │ │ └── container.png
│ │ └── ex9
│ │ │ ├── AdvancedForLoop.java
│ │ │ ├── AdvancedForLoop.md
│ │ │ └── metadata
│ │ │ ├── 0.jpg
│ │ │ ├── 1.jpg
│ │ │ └── 2.jpg
│ │ ├── maven
│ │ ├── RunMaven.java
│ │ ├── RunMaven.md
│ │ └── metadata
│ │ │ ├── dependency_0.jpg
│ │ │ ├── dependency_1.jpg
│ │ │ ├── dependency_2.jpg
│ │ │ ├── dependency_3.jpg
│ │ │ ├── import0.jpg
│ │ │ ├── import_1.jpg
│ │ │ ├── import_2.jpg
│ │ │ ├── invalidate.jpg
│ │ │ ├── java.png
│ │ │ ├── javaEnv.jpg
│ │ │ ├── javarelease.jpg
│ │ │ ├── javaversion.jpg
│ │ │ ├── m2.jpg
│ │ │ ├── maven0.jpg
│ │ │ ├── maven1.jpg
│ │ │ ├── maven2.jpg
│ │ │ ├── maven3.jpg
│ │ │ ├── maven4.jpg
│ │ │ ├── maven_0.png
│ │ │ ├── maven_create_project_0.png
│ │ │ ├── maven_create_project_0_0.png
│ │ │ ├── maven_create_project_1.png
│ │ │ ├── maven_create_project_2.png
│ │ │ ├── maven_create_project_3.png
│ │ │ ├── maven_graphic_0.jpg
│ │ │ ├── maven_graphic_1.jpg
│ │ │ ├── maven_graphic_2.jpg
│ │ │ ├── pom_.jpg
│ │ │ ├── pom_1.png
│ │ │ ├── pom_2.png
│ │ │ ├── reload.jpg
│ │ │ └── simplest_pom.png
│ │ ├── quickstart.md
│ │ └── util
│ │ ├── Config.java
│ │ ├── Conversion.java
│ │ ├── Dashboard.java
│ │ ├── FileLoader.java
│ │ ├── InputParser.java
│ │ ├── OutputParser.java
│ │ ├── PathHandler.java
│ │ └── SpringUtilities.java
│ └── resources
│ ├── ai
│ └── certifai
│ │ ├── basic
│ │ ├── ex1
│ │ │ └── HelloWorld
│ │ │ │ └── output.txt
│ │ ├── ex2
│ │ │ └── PackagingIntro
│ │ │ │ └── output.txt
│ │ ├── ex3
│ │ │ └── BluePrint
│ │ │ │ ├── input.txt
│ │ │ │ └── output.txt
│ │ ├── ex5
│ │ │ └── If_ElseIf_Else
│ │ │ │ ├── input.txt
│ │ │ │ └── output.txt
│ │ ├── ex6
│ │ │ └── DataTypes
│ │ │ │ ├── input.txt
│ │ │ │ └── output.txt
│ │ └── ex7
│ │ │ └── ForLoop
│ │ │ ├── input.txt
│ │ │ └── output.txt
│ │ └── intermediate
│ │ ├── ex10
│ │ └── ExceptionHandling
│ │ │ └── output.txt
│ │ ├── ex11
│ │ └── WhileLoop
│ │ │ ├── 1.txt
│ │ │ ├── 2.txt
│ │ │ ├── 3.txt
│ │ │ ├── 4.txt
│ │ │ ├── 5.txt
│ │ │ ├── 6.txt
│ │ │ ├── 7.txt
│ │ │ ├── input.txt
│ │ │ └── output.txt
│ │ ├── ex12
│ │ └── MapImp
│ │ │ ├── input.txt
│ │ │ └── output.txt
│ │ ├── ex13
│ │ └── SubString
│ │ │ ├── input.txt
│ │ │ └── output.txt
│ │ ├── ex14
│ │ └── AdvancedSubString
│ │ │ ├── input.txt
│ │ │ └── output.txt
│ │ ├── ex15
│ │ └── QuickSortImp
│ │ │ ├── input.txt
│ │ │ └── output.txt
│ │ ├── ex8
│ │ └── OrderedCollection
│ │ │ ├── input.txt
│ │ │ └── output.txt
│ │ └── ex9
│ │ └── AdvancedForLoop
│ │ ├── input.txt
│ │ └── output.txt
│ └── solutionStructureGuidance.md
├── metadata
├── codeSample.JPG
├── dashboard.jpg
├── fileStructure.jpg
├── head.gif
└── try.jpg
└── pom.xml
/.github/ISSUE_TEMPLATE/---bug-report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "\U0001F41B Bug report"
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | ## Describe the bug
11 | A clear and concise description of what the bug is.
12 |
13 | ## To Reproduce
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | ## Expected behavior
21 | A clear and concise description of what you expected to happen.
22 |
23 | ## Screenshots
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | ## Desktop Details (please complete the following information):
27 | - OS: [e.g. Windows]
28 | - Browser [e.g. Chrome, Safari]
29 | - Version [e.g. 22]
30 |
31 | ## Additional context
32 | Add any other context about the problem here.
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/---documentation.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "\U0001F4DA Documentation"
3 | about: Report an issue with regards to TrainingLabs documentation in Readme or Wiki
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | ## Readme/Wiki Page
11 | Write down the page name or URL here.
12 |
13 | ## Faulty/Unclear Documentation
14 | A clear and concise description of where the documentation is unclear or inaccurate.
15 |
16 | Attach screenshot here if possible.
17 |
18 | ## Suggested Edits
19 | Kindly suggest edits as candidates to replace the inaccurate documentation, if applicable.
20 |
21 | ## Additional context
22 | Add any other context about the problem here.
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | # Description
2 |
3 | Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
4 |
5 | Fixes # (issue)
6 |
7 | ## Type of change
8 |
9 | - [ ] New Exercise
10 | - [ ] Bug fix (non-breaking change which fixes an issue)
11 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
12 | - [ ] This change requires a documentation update
13 | - [ ] Adding automation capabilities with GitHub Action
14 |
15 | # Tested on?
16 |
17 | - [ ] Windows
18 | - [ ] Linux Ubuntu
19 | - [ ] Centos
20 | - [ ] Mac
21 | - [ ] Others (State here -> xxx )
22 |
23 | # Checklist:
24 |
25 | - [ ] My code follows the style guidelines of this project
26 | - [ ] I have performed a self-review of my own code
27 | - [ ] I have commented my code, particularly in hard-to-understand areas
28 | - [ ] I have made corresponding changes to the documentation
29 | - [ ] My changes generate no new warnings
30 | - [ ] I have added tests that prove my fix is effective or that my feature works
31 | - [ ] New and existing unit tests pass locally with my changes
32 | - [ ] Any dependent changes have been merged
33 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | # This code will build the Java project with Maven and execute code test with Sonar Cloud
2 |
3 | name: Build & Sonar Test
4 | on:
5 | push:
6 | branches:
7 | - main
8 |
9 | pull_request:
10 | types: [synchronize, review_requested]
11 |
12 | jobs:
13 | build:
14 | name: Build with Maven
15 | runs-on: ubuntu-latest
16 | steps:
17 | - uses: actions/checkout@v2
18 |
19 | - name: Set up JDK 11
20 | uses: actions/setup-java@v2
21 | with:
22 | java-version: '11'
23 | distribution: 'zulu'
24 |
25 | - name: Cache Maven packages
26 | uses: actions/cache@v1
27 | with:
28 | path: ~/.m2
29 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
30 | restore-keys: ${{ runner.os }}-m2
31 |
32 | - name: Build Project
33 | run: mvn -B verify
34 |
35 | sonar:
36 | name: Build & Test with Sonar Cloud
37 | runs-on: ubuntu-latest
38 | steps:
39 | - uses: actions/checkout@v2
40 | with:
41 | fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
42 |
43 | - name: Set up JDK 11
44 | uses: actions/setup-java@v2
45 | with:
46 | java-version: '11'
47 | distribution: 'zulu'
48 |
49 | - name: Cache SonarCloud packages
50 | uses: actions/cache@v1
51 | with:
52 | path: ~/.sonar/cache
53 | key: ${{ runner.os }}-sonar
54 | restore-keys: ${{ runner.os }}-sonar
55 |
56 | - name: Cache Maven packages
57 | uses: actions/cache@v1
58 | with:
59 | path: ~/.m2
60 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
61 | restore-keys: ${{ runner.os }}-m2
62 |
63 | - name: Build and analyze
64 | env:
65 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
67 | run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | hs_err_pid*
23 |
24 | # mac file
25 | .DS_Store
26 |
27 | target/
28 |
29 | *.class
30 | .idea/*
31 | *.iml
32 | *.tmp
33 |
34 | #log file
35 | *.log
36 |
37 | output/*
38 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | learn-java-the-certifai-way
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
19 | 1621387210162
20 |
21 | 30
22 |
23 | org.eclipse.core.resources.regexFilterMatcher
24 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for
11 | software and other kinds of works, specifically designed to ensure
12 | cooperation with the community in the case of network server software.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | our General Public Licenses are intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users.
19 |
20 | When we speak of free software, we are referring to freedom, not
21 | price. Our General Public Licenses are designed to make sure that you
22 | have the freedom to distribute copies of free software (and charge for
23 | them if you wish), that you receive source code or can get it if you
24 | want it, that you can change the software or use pieces of it in new
25 | free programs, and that you know you can do these things.
26 |
27 | Developers that use our General Public Licenses protect your rights
28 | with two steps: (1) assert copyright on the software, and (2) offer
29 | you this License which gives you legal permission to copy, distribute
30 | and/or modify the software.
31 |
32 | A secondary benefit of defending all users' freedom is that
33 | improvements made in alternate versions of the program, if they
34 | receive widespread use, become available for other developers to
35 | incorporate. Many developers of free software are heartened and
36 | encouraged by the resulting cooperation. However, in the case of
37 | software used on network servers, this result may fail to come about.
38 | The GNU General Public License permits making a modified version and
39 | letting the public access it on a server without ever releasing its
40 | source code to the public.
41 |
42 | The GNU Affero General Public License is designed specifically to
43 | ensure that, in such cases, the modified source code becomes available
44 | to the community. It requires the operator of a network server to
45 | provide the source code of the modified version running there to the
46 | users of that server. Therefore, public use of a modified version, on
47 | a publicly accessible server, gives the public access to the source
48 | code of the modified version.
49 |
50 | An older license, called the Affero General Public License and
51 | published by Affero, was designed to accomplish similar goals. This is
52 | a different license, not a version of the Affero GPL, but Affero has
53 | released a new version of the Affero GPL which permits relicensing under
54 | this license.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | TERMS AND CONDITIONS
60 |
61 | 0. Definitions.
62 |
63 | "This License" refers to version 3 of the GNU Affero General Public License.
64 |
65 | "Copyright" also means copyright-like laws that apply to other kinds of
66 | works, such as semiconductor masks.
67 |
68 | "The Program" refers to any copyrightable work licensed under this
69 | License. Each licensee is addressed as "you". "Licensees" and
70 | "recipients" may be individuals or organizations.
71 |
72 | To "modify" a work means to copy from or adapt all or part of the work
73 | in a fashion requiring copyright permission, other than the making of an
74 | exact copy. The resulting work is called a "modified version" of the
75 | earlier work or a work "based on" the earlier work.
76 |
77 | A "covered work" means either the unmodified Program or a work based
78 | on the Program.
79 |
80 | To "propagate" a work means to do anything with it that, without
81 | permission, would make you directly or secondarily liable for
82 | infringement under applicable copyright law, except executing it on a
83 | computer or modifying a private copy. Propagation includes copying,
84 | distribution (with or without modification), making available to the
85 | public, and in some countries other activities as well.
86 |
87 | To "convey" a work means any kind of propagation that enables other
88 | parties to make or receive copies. Mere interaction with a user through
89 | a computer network, with no transfer of a copy, is not conveying.
90 |
91 | An interactive user interface displays "Appropriate Legal Notices"
92 | to the extent that it includes a convenient and prominently visible
93 | feature that (1) displays an appropriate copyright notice, and (2)
94 | tells the user that there is no warranty for the work (except to the
95 | extent that warranties are provided), that licensees may convey the
96 | work under this License, and how to view a copy of this License. If
97 | the interface presents a list of user commands or options, such as a
98 | menu, a prominent item in the list meets this criterion.
99 |
100 | 1. Source Code.
101 |
102 | The "source code" for a work means the preferred form of the work
103 | for making modifications to it. "Object code" means any non-source
104 | form of a work.
105 |
106 | A "Standard Interface" means an interface that either is an official
107 | standard defined by a recognized standards body, or, in the case of
108 | interfaces specified for a particular programming language, one that
109 | is widely used among developers working in that language.
110 |
111 | The "System Libraries" of an executable work include anything, other
112 | than the work as a whole, that (a) is included in the normal form of
113 | packaging a Major Component, but which is not part of that Major
114 | Component, and (b) serves only to enable use of the work with that
115 | Major Component, or to implement a Standard Interface for which an
116 | implementation is available to the public in source code form. A
117 | "Major Component", in this context, means a major essential component
118 | (kernel, window system, and so on) of the specific operating system
119 | (if any) on which the executable work runs, or a compiler used to
120 | produce the work, or an object code interpreter used to run it.
121 |
122 | The "Corresponding Source" for a work in object code form means all
123 | the source code needed to generate, install, and (for an executable
124 | work) run the object code and to modify the work, including scripts to
125 | control those activities. However, it does not include the work's
126 | System Libraries, or general-purpose tools or generally available free
127 | programs which are used unmodified in performing those activities but
128 | which are not part of the work. For example, Corresponding Source
129 | includes interface definition files associated with source files for
130 | the work, and the source code for shared libraries and dynamically
131 | linked subprograms that the work is specifically designed to require,
132 | such as by intimate data communication or control flow between those
133 | subprograms and other parts of the work.
134 |
135 | The Corresponding Source need not include anything that users
136 | can regenerate automatically from other parts of the Corresponding
137 | Source.
138 |
139 | The Corresponding Source for a work in source code form is that
140 | same work.
141 |
142 | 2. Basic Permissions.
143 |
144 | All rights granted under this License are granted for the term of
145 | copyright on the Program, and are irrevocable provided the stated
146 | conditions are met. This License explicitly affirms your unlimited
147 | permission to run the unmodified Program. The output from running a
148 | covered work is covered by this License only if the output, given its
149 | content, constitutes a covered work. This License acknowledges your
150 | rights of fair use or other equivalent, as provided by copyright law.
151 |
152 | You may make, run and propagate covered works that you do not
153 | convey, without conditions so long as your license otherwise remains
154 | in force. You may convey covered works to others for the sole purpose
155 | of having them make modifications exclusively for you, or provide you
156 | with facilities for running those works, provided that you comply with
157 | the terms of this License in conveying all material for which you do
158 | not control copyright. Those thus making or running the covered works
159 | for you must do so exclusively on your behalf, under your direction
160 | and control, on terms that prohibit them from making any copies of
161 | your copyrighted material outside their relationship with you.
162 |
163 | Conveying under any other circumstances is permitted solely under
164 | the conditions stated below. Sublicensing is not allowed; section 10
165 | makes it unnecessary.
166 |
167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168 |
169 | No covered work shall be deemed part of an effective technological
170 | measure under any applicable law fulfilling obligations under article
171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 | similar laws prohibiting or restricting circumvention of such
173 | measures.
174 |
175 | When you convey a covered work, you waive any legal power to forbid
176 | circumvention of technological measures to the extent such circumvention
177 | is effected by exercising rights under this License with respect to
178 | the covered work, and you disclaim any intention to limit operation or
179 | modification of the work as a means of enforcing, against the work's
180 | users, your or third parties' legal rights to forbid circumvention of
181 | technological measures.
182 |
183 | 4. Conveying Verbatim Copies.
184 |
185 | You may convey verbatim copies of the Program's source code as you
186 | receive it, in any medium, provided that you conspicuously and
187 | appropriately publish on each copy an appropriate copyright notice;
188 | keep intact all notices stating that this License and any
189 | non-permissive terms added in accord with section 7 apply to the code;
190 | keep intact all notices of the absence of any warranty; and give all
191 | recipients a copy of this License along with the Program.
192 |
193 | You may charge any price or no price for each copy that you convey,
194 | and you may offer support or warranty protection for a fee.
195 |
196 | 5. Conveying Modified Source Versions.
197 |
198 | You may convey a work based on the Program, or the modifications to
199 | produce it from the Program, in the form of source code under the
200 | terms of section 4, provided that you also meet all of these conditions:
201 |
202 | a) The work must carry prominent notices stating that you modified
203 | it, and giving a relevant date.
204 |
205 | b) The work must carry prominent notices stating that it is
206 | released under this License and any conditions added under section
207 | 7. This requirement modifies the requirement in section 4 to
208 | "keep intact all notices".
209 |
210 | c) You must license the entire work, as a whole, under this
211 | License to anyone who comes into possession of a copy. This
212 | License will therefore apply, along with any applicable section 7
213 | additional terms, to the whole of the work, and all its parts,
214 | regardless of how they are packaged. This License gives no
215 | permission to license the work in any other way, but it does not
216 | invalidate such permission if you have separately received it.
217 |
218 | d) If the work has interactive user interfaces, each must display
219 | Appropriate Legal Notices; however, if the Program has interactive
220 | interfaces that do not display Appropriate Legal Notices, your
221 | work need not make them do so.
222 |
223 | A compilation of a covered work with other separate and independent
224 | works, which are not by their nature extensions of the covered work,
225 | and which are not combined with it such as to form a larger program,
226 | in or on a volume of a storage or distribution medium, is called an
227 | "aggregate" if the compilation and its resulting copyright are not
228 | used to limit the access or legal rights of the compilation's users
229 | beyond what the individual works permit. Inclusion of a covered work
230 | in an aggregate does not cause this License to apply to the other
231 | parts of the aggregate.
232 |
233 | 6. Conveying Non-Source Forms.
234 |
235 | You may convey a covered work in object code form under the terms
236 | of sections 4 and 5, provided that you also convey the
237 | machine-readable Corresponding Source under the terms of this License,
238 | in one of these ways:
239 |
240 | a) Convey the object code in, or embodied in, a physical product
241 | (including a physical distribution medium), accompanied by the
242 | Corresponding Source fixed on a durable physical medium
243 | customarily used for software interchange.
244 |
245 | b) Convey the object code in, or embodied in, a physical product
246 | (including a physical distribution medium), accompanied by a
247 | written offer, valid for at least three years and valid for as
248 | long as you offer spare parts or customer support for that product
249 | model, to give anyone who possesses the object code either (1) a
250 | copy of the Corresponding Source for all the software in the
251 | product that is covered by this License, on a durable physical
252 | medium customarily used for software interchange, for a price no
253 | more than your reasonable cost of physically performing this
254 | conveying of source, or (2) access to copy the
255 | Corresponding Source from a network server at no charge.
256 |
257 | c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 |
263 | d) Convey the object code by offering access from a designated
264 | place (gratis or for a charge), and offer equivalent access to the
265 | Corresponding Source in the same way through the same place at no
266 | further charge. You need not require recipients to copy the
267 | Corresponding Source along with the object code. If the place to
268 | copy the object code is a network server, the Corresponding Source
269 | may be on a different server (operated by you or a third party)
270 | that supports equivalent copying facilities, provided you maintain
271 | clear directions next to the object code saying where to find the
272 | Corresponding Source. Regardless of what server hosts the
273 | Corresponding Source, you remain obligated to ensure that it is
274 | available for as long as needed to satisfy these requirements.
275 |
276 | e) Convey the object code using peer-to-peer transmission, provided
277 | you inform other peers where the object code and Corresponding
278 | Source of the work are being offered to the general public at no
279 | charge under subsection 6d.
280 |
281 | A separable portion of the object code, whose source code is excluded
282 | from the Corresponding Source as a System Library, need not be
283 | included in conveying the object code work.
284 |
285 | A "User Product" is either (1) a "consumer product", which means any
286 | tangible personal property which is normally used for personal, family,
287 | or household purposes, or (2) anything designed or sold for incorporation
288 | into a dwelling. In determining whether a product is a consumer product,
289 | doubtful cases shall be resolved in favor of coverage. For a particular
290 | product received by a particular user, "normally used" refers to a
291 | typical or common use of that class of product, regardless of the status
292 | of the particular user or of the way in which the particular user
293 | actually uses, or expects or is expected to use, the product. A product
294 | is a consumer product regardless of whether the product has substantial
295 | commercial, industrial or non-consumer uses, unless such uses represent
296 | the only significant mode of use of the product.
297 |
298 | "Installation Information" for a User Product means any methods,
299 | procedures, authorization keys, or other information required to install
300 | and execute modified versions of a covered work in that User Product from
301 | a modified version of its Corresponding Source. The information must
302 | suffice to ensure that the continued functioning of the modified object
303 | code is in no case prevented or interfered with solely because
304 | modification has been made.
305 |
306 | If you convey an object code work under this section in, or with, or
307 | specifically for use in, a User Product, and the conveying occurs as
308 | part of a transaction in which the right of possession and use of the
309 | User Product is transferred to the recipient in perpetuity or for a
310 | fixed term (regardless of how the transaction is characterized), the
311 | Corresponding Source conveyed under this section must be accompanied
312 | by the Installation Information. But this requirement does not apply
313 | if neither you nor any third party retains the ability to install
314 | modified object code on the User Product (for example, the work has
315 | been installed in ROM).
316 |
317 | The requirement to provide Installation Information does not include a
318 | requirement to continue to provide support service, warranty, or updates
319 | for a work that has been modified or installed by the recipient, or for
320 | the User Product in which it has been modified or installed. Access to a
321 | network may be denied when the modification itself materially and
322 | adversely affects the operation of the network or violates the rules and
323 | protocols for communication across the network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders of
351 | that material) supplement the terms of this License with terms:
352 |
353 | a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 |
356 | b) Requiring preservation of specified reasonable legal notices or
357 | author attributions in that material or in the Appropriate Legal
358 | Notices displayed by works containing it; or
359 |
360 | c) Prohibiting misrepresentation of the origin of that material, or
361 | requiring that modified versions of such material be marked in
362 | reasonable ways as different from the original version; or
363 |
364 | d) Limiting the use for publicity purposes of names of licensors or
365 | authors of the material; or
366 |
367 | e) Declining to grant rights under trademark law for use of some
368 | trade names, trademarks, or service marks; or
369 |
370 | f) Requiring indemnification of licensors and authors of that
371 | material by anyone who conveys the material (or modified versions of
372 | it) with contractual assumptions of liability to the recipient, for
373 | any liability that these contractual assumptions directly impose on
374 | those licensors and authors.
375 |
376 | All other non-permissive additional terms are considered "further
377 | restrictions" within the meaning of section 10. If the Program as you
378 | received it, or any part of it, contains a notice stating that it is
379 | governed by this License along with a term that is a further
380 | restriction, you may remove that term. If a license document contains
381 | a further restriction but permits relicensing or conveying under this
382 | License, you may add to a covered work material governed by the terms
383 | of that license document, provided that the further restriction does
384 | not survive such relicensing or conveying.
385 |
386 | If you add terms to a covered work in accord with this section, you
387 | must place, in the relevant source files, a statement of the
388 | additional terms that apply to those files, or a notice indicating
389 | where to find the applicable terms.
390 |
391 | Additional terms, permissive or non-permissive, may be stated in the
392 | form of a separately written license, or stated as exceptions;
393 | the above requirements apply either way.
394 |
395 | 8. Termination.
396 |
397 | You may not propagate or modify a covered work except as expressly
398 | provided under this License. Any attempt otherwise to propagate or
399 | modify it is void, and will automatically terminate your rights under
400 | this License (including any patent licenses granted under the third
401 | paragraph of section 11).
402 |
403 | However, if you cease all violation of this License, then your
404 | license from a particular copyright holder is reinstated (a)
405 | provisionally, unless and until the copyright holder explicitly and
406 | finally terminates your license, and (b) permanently, if the copyright
407 | holder fails to notify you of the violation by some reasonable means
408 | prior to 60 days after the cessation.
409 |
410 | Moreover, your license from a particular copyright holder is
411 | reinstated permanently if the copyright holder notifies you of the
412 | violation by some reasonable means, this is the first time you have
413 | received notice of violation of this License (for any work) from that
414 | copyright holder, and you cure the violation prior to 30 days after
415 | your receipt of the notice.
416 |
417 | Termination of your rights under this section does not terminate the
418 | licenses of parties who have received copies or rights from you under
419 | this License. If your rights have been terminated and not permanently
420 | reinstated, you do not qualify to receive new licenses for the same
421 | material under section 10.
422 |
423 | 9. Acceptance Not Required for Having Copies.
424 |
425 | You are not required to accept this License in order to receive or
426 | run a copy of the Program. Ancillary propagation of a covered work
427 | occurring solely as a consequence of using peer-to-peer transmission
428 | to receive a copy likewise does not require acceptance. However,
429 | nothing other than this License grants you permission to propagate or
430 | modify any covered work. These actions infringe copyright if you do
431 | not accept this License. Therefore, by modifying or propagating a
432 | covered work, you indicate your acceptance of this License to do so.
433 |
434 | 10. Automatic Licensing of Downstream Recipients.
435 |
436 | Each time you convey a covered work, the recipient automatically
437 | receives a license from the original licensors, to run, modify and
438 | propagate that work, subject to this License. You are not responsible
439 | for enforcing compliance by third parties with this License.
440 |
441 | An "entity transaction" is a transaction transferring control of an
442 | organization, or substantially all assets of one, or subdividing an
443 | organization, or merging organizations. If propagation of a covered
444 | work results from an entity transaction, each party to that
445 | transaction who receives a copy of the work also receives whatever
446 | licenses to the work the party's predecessor in interest had or could
447 | give under the previous paragraph, plus a right to possession of the
448 | Corresponding Source of the work from the predecessor in interest, if
449 | the predecessor has it or can get it with reasonable efforts.
450 |
451 | You may not impose any further restrictions on the exercise of the
452 | rights granted or affirmed under this License. For example, you may
453 | not impose a license fee, royalty, or other charge for exercise of
454 | rights granted under this License, and you may not initiate litigation
455 | (including a cross-claim or counterclaim in a lawsuit) alleging that
456 | any patent claim is infringed by making, using, selling, offering for
457 | sale, or importing the Program or any portion of it.
458 |
459 | 11. Patents.
460 |
461 | A "contributor" is a copyright holder who authorizes use under this
462 | License of the Program or a work on which the Program is based. The
463 | work thus licensed is called the contributor's "contributor version".
464 |
465 | A contributor's "essential patent claims" are all patent claims
466 | owned or controlled by the contributor, whether already acquired or
467 | hereafter acquired, that would be infringed by some manner, permitted
468 | by this License, of making, using, or selling its contributor version,
469 | but do not include claims that would be infringed only as a
470 | consequence of further modification of the contributor version. For
471 | purposes of this definition, "control" includes the right to grant
472 | patent sublicenses in a manner consistent with the requirements of
473 | this License.
474 |
475 | Each contributor grants you a non-exclusive, worldwide, royalty-free
476 | patent license under the contributor's essential patent claims, to
477 | make, use, sell, offer for sale, import and otherwise run, modify and
478 | propagate the contents of its contributor version.
479 |
480 | In the following three paragraphs, a "patent license" is any express
481 | agreement or commitment, however denominated, not to enforce a patent
482 | (such as an express permission to practice a patent or covenant not to
483 | sue for patent infringement). To "grant" such a patent license to a
484 | party means to make such an agreement or commitment not to enforce a
485 | patent against the party.
486 |
487 | If you convey a covered work, knowingly relying on a patent license,
488 | and the Corresponding Source of the work is not available for anyone
489 | to copy, free of charge and under the terms of this License, through a
490 | publicly available network server or other readily accessible means,
491 | then you must either (1) cause the Corresponding Source to be so
492 | available, or (2) arrange to deprive yourself of the benefit of the
493 | patent license for this particular work, or (3) arrange, in a manner
494 | consistent with the requirements of this License, to extend the patent
495 | license to downstream recipients. "Knowingly relying" means you have
496 | actual knowledge that, but for the patent license, your conveying the
497 | covered work in a country, or your recipient's use of the covered work
498 | in a country, would infringe one or more identifiable patents in that
499 | country that you have reason to believe are valid.
500 |
501 | If, pursuant to or in connection with a single transaction or
502 | arrangement, you convey, or propagate by procuring conveyance of, a
503 | covered work, and grant a patent license to some of the parties
504 | receiving the covered work authorizing them to use, propagate, modify
505 | or convey a specific copy of the covered work, then the patent license
506 | you grant is automatically extended to all recipients of the covered
507 | work and works based on it.
508 |
509 | A patent license is "discriminatory" if it does not include within
510 | the scope of its coverage, prohibits the exercise of, or is
511 | conditioned on the non-exercise of one or more of the rights that are
512 | specifically granted under this License. You may not convey a covered
513 | work if you are a party to an arrangement with a third party that is
514 | in the business of distributing software, under which you make payment
515 | to the third party based on the extent of your activity of conveying
516 | the work, and under which the third party grants, to any of the
517 | parties who would receive the covered work from you, a discriminatory
518 | patent license (a) in connection with copies of the covered work
519 | conveyed by you (or copies made from those copies), or (b) primarily
520 | for and in connection with specific products or compilations that
521 | contain the covered work, unless you entered into that arrangement,
522 | or that patent license was granted, prior to 28 March 2007.
523 |
524 | Nothing in this License shall be construed as excluding or limiting
525 | any implied license or other defenses to infringement that may
526 | otherwise be available to you under applicable patent law.
527 |
528 | 12. No Surrender of Others' Freedom.
529 |
530 | If conditions are imposed on you (whether by court order, agreement or
531 | otherwise) that contradict the conditions of this License, they do not
532 | excuse you from the conditions of this License. If you cannot convey a
533 | covered work so as to satisfy simultaneously your obligations under this
534 | License and any other pertinent obligations, then as a consequence you may
535 | not convey it at all. For example, if you agree to terms that obligate you
536 | to collect a royalty for further conveying from those to whom you convey
537 | the Program, the only way you could satisfy both those terms and this
538 | License would be to refrain entirely from conveying the Program.
539 |
540 | 13. Remote Network Interaction; Use with the GNU General Public License.
541 |
542 | Notwithstanding any other provision of this License, if you modify the
543 | Program, your modified version must prominently offer all users
544 | interacting with it remotely through a computer network (if your version
545 | supports such interaction) an opportunity to receive the Corresponding
546 | Source of your version by providing access to the Corresponding Source
547 | from a network server at no charge, through some standard or customary
548 | means of facilitating copying of software. This Corresponding Source
549 | shall include the Corresponding Source for any work covered by version 3
550 | of the GNU General Public License that is incorporated pursuant to the
551 | following paragraph.
552 |
553 | Notwithstanding any other provision of this License, you have
554 | permission to link or combine any covered work with a work licensed
555 | under version 3 of the GNU General Public License into a single
556 | combined work, and to convey the resulting work. The terms of this
557 | License will continue to apply to the part which is the covered work,
558 | but the work with which it is combined will remain governed by version
559 | 3 of the GNU General Public License.
560 |
561 | 14. Revised Versions of this License.
562 |
563 | The Free Software Foundation may publish revised and/or new versions of
564 | the GNU Affero General Public License from time to time. Such new versions
565 | will be similar in spirit to the present version, but may differ in detail to
566 | address new problems or concerns.
567 |
568 | Each version is given a distinguishing version number. If the
569 | Program specifies that a certain numbered version of the GNU Affero General
570 | Public License "or any later version" applies to it, you have the
571 | option of following the terms and conditions either of that numbered
572 | version or of any later version published by the Free Software
573 | Foundation. If the Program does not specify a version number of the
574 | GNU Affero General Public License, you may choose any version ever published
575 | by the Free Software Foundation.
576 |
577 | If the Program specifies that a proxy can decide which future
578 | versions of the GNU Affero General Public License can be used, that proxy's
579 | public statement of acceptance of a version permanently authorizes you
580 | to choose that version for the Program.
581 |
582 | Later license versions may give you additional or different
583 | permissions. However, no additional obligations are imposed on any
584 | author or copyright holder as a result of your choosing to follow a
585 | later version.
586 |
587 | 15. Disclaimer of Warranty.
588 |
589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597 |
598 | 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 | SUCH DAMAGES.
609 |
610 | 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 | How to Apply These Terms to Your New Programs
622 |
623 | If you develop a new program, and you want it to be of the greatest
624 | possible use to the public, the best way to achieve this is to make it
625 | free software which everyone can redistribute and change under these terms.
626 |
627 | To do so, attach the following notices to the program. It is safest
628 | to attach them to the start of each source file to most effectively
629 | state the exclusion of warranty; and each file should have at least
630 | the "copyright" line and a pointer to where the full notice is found.
631 |
632 |
633 | Copyright (C)
634 |
635 | This program is free software: you can redistribute it and/or modify
636 | it under the terms of the GNU Affero General Public License as published
637 | by the Free Software Foundation, either version 3 of the License, or
638 | (at your option) any later version.
639 |
640 | This program is distributed in the hope that it will be useful,
641 | but WITHOUT ANY WARRANTY; without even the implied warranty of
642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 | GNU Affero General Public License for more details.
644 |
645 | You should have received a copy of the GNU Affero General Public License
646 | along with this program. If not, see .
647 |
648 | Also add information on how to contact you by electronic and paper mail.
649 |
650 | If your software can interact with users remotely through a computer
651 | network, you should also make sure that it provides a way for users to
652 | get its source. For example, if your program is a web application, its
653 | interface could display a "Source" link that leads users to an archive
654 | of the code. There are many ways you could offer source, and different
655 | solutions will be better for different programs; see section 13 for the
656 | specific requirements.
657 |
658 | You should also get your employer (if you work as a programmer) or school,
659 | if any, to sign a "copyright disclaimer" for the program, if necessary.
660 | For more information on this, and how to apply and follow the GNU AGPL, see
661 | .
662 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
27 |
28 | ## What You Will Learn
29 | - Through the building blocks of Java snippets, you will able to understand the gist of Java programming in no time.
30 |
31 | ## What You Need
32 | - Grit to go through the repository!
33 | - [Oracle JDK 1.8](https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html) or alternative open source JDK 1.8 version
34 | - As of today, the repository was tested with
35 | - Oracle JDK 1.8
36 | - OpenJDK 1.8
37 | - BellSoft Liberica JDK 1.8
38 | - [Apache Maven 3.5](https://maven.apache.org/download.cgi) or later
39 | - [Intellij IDE](https://www.jetbrains.com/idea/download/)
40 |
41 | **Takeaway:**
42 | - Java - Programming Language
43 | - Apache Maven - Java Dependency Manager
44 | - Intellij IDE - Editor
45 |
46 |
47 | ## Repository Structure
48 |
49 | - [**Basic**](https://github.com/CertifaiAI/learn-java-the-certifai-way/tree/master/java-core/src/main/java/ai/certifai/basic)
50 | - [**Introduction to Apache Maven**](https://github.com/CertifaiAI/learn-java-the-certifai-way/tree/master/java-core/src/main/java/ai/certifai/maven)
51 | - [**Intermediate**](https://github.com/CertifaiAI/learn-java-the-certifai-way/tree/master/java-core/src/main/java/ai/certifai/intermediate)
52 |
53 | In order to gain the most benefits, choose the topic to look deeper into at your own pace.
54 |
55 | If starting from scratch, walkthrough the folder in the above order to gain the maximum learning experience.
56 |
57 | ## How to Use This Repository
58 |
59 | - Guides in the form of markdown in each ex* folder will shows what to do in the particular exercise.
60 |
61 |
62 |
63 |
64 | - Only modify program code in the designated area in each exercise. \
65 | Markdown in each specific folder will provide a more detailed instructions.
66 |
67 |
68 |
69 |
70 |
71 |
72 | - No answer will be provided. The use cases were carefully designed to determine the successful run of the code.
73 |
74 |
75 |
76 |
77 | - Don't memorize the code. Human have horrrible memories. It WONT bring you anywhere.
78 |
79 |
80 |
81 |
82 |
83 | - Try the very best to craft the answer through getting the hands dirty. Follow your own pace.
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/java-core/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/java-core/.factorypath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/java-core/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | java-core
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
25 | 1621387210158
26 |
27 | 30
28 |
29 | org.eclipse.core.resources.regexFilterMatcher
30 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/java-core/.settings/org.eclipse.jdt.apt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.apt.aptEnabled=true
3 | org.eclipse.jdt.apt.genSrcDir=target/generated-sources/annotations
4 | org.eclipse.jdt.apt.genTestSrcDir=target/generated-test-sources/test-annotations
5 |
--------------------------------------------------------------------------------
/java-core/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
3 | org.eclipse.jdt.core.compiler.compliance=1.8
4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
7 | org.eclipse.jdt.core.compiler.processAnnotations=enabled
8 | org.eclipse.jdt.core.compiler.release=disabled
9 | org.eclipse.jdt.core.compiler.source=1.8
10 |
--------------------------------------------------------------------------------
/java-core/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/java-core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
20 |
21 | ai.certifai
22 | learn-java-the-certifai-way
23 | 1.0-SNAPSHOT
24 |
25 |
26 | 4.0.0
27 | java-core
28 | java-core
29 |
30 |
31 |
32 | org.apache.maven.plugins
33 | maven-compiler-plugin
34 |
35 | 8
36 | 8
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | org.projectlombok
46 | lombok
47 | 1.18.12
48 |
49 |
50 | org.slf4j
51 | slf4j-api
52 | 1.7.26
53 |
54 |
55 | ch.qos.logback
56 | logback-classic
57 | 1.2.3
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex1/HelloWorld.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.basic.ex1;
18 |
19 | import ai.certifai.util.OutputParser;
20 |
21 |
22 | /**
23 | * Iconic Hello World Quickstart
24 | *
25 | * @author codenamewei
26 | */
27 | class HelloWorld
28 | {
29 | static OutputParser out;
30 |
31 | public static void main(String[] args)
32 | {
33 | out = new OutputParser(HelloWorld.class);
34 |
35 | /**
36 | Enter your code here
37 | Complete the program by making changes to line 38
38 | Tips: change the content assign to variable firstString
39 | **/
40 | String firstString = null;
41 |
42 | out.evaluate(firstString);
43 |
44 | out.printResult();
45 | }
46 | }
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex1/HelloWorld.md:
--------------------------------------------------------------------------------
1 | # QuickStart!
2 |
3 | **What To Do**
4 | Pass string of `Hello World!` to the variable [_firstString_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/basic/ex1/HelloWorld.java#L38)
5 |
6 |
7 | **Sample Output**
8 | `
9 | Hello World!
10 | `
11 |
12 | **Key Takeaways**
13 |
14 |
15 |
16 |
17 |
18 | - Class name should be in the form of Noun, where each word first letter is of capital letter.
19 | This naming convention is **CamelCase**.
20 | - Example:
21 | - HelloWorld
22 | - BluePrint
23 | - DataTypes
24 | - ExceptionHandling
25 |
26 | - Non-static non-final name use **CamelCase** as well, with first word being small case.
27 |
28 | - There should be **one public class name per file**
29 |
30 | - The class name must be same with file name for Java to recognize the entry point.
31 | There should be a **public** access modified before it.
32 | Else will throw a compile time error. (Try it :computer:)
33 |
34 | - Contrary to Python, each line should end with semicolon.
35 |
36 |
37 | **Quiz**
38 | 1. Can more than 1 class appear in one .java file? (Try it :computer:)
39 |
40 | 2. What do you understand about the line [_package ai.certifai.basic.ex1;_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/basic/ex1/HelloWorld.java#L16)?
41 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex1/metadata/publicClass.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex1/metadata/publicClass.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex2/PackagingIntro.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.basic.ex2;
18 |
19 | import ai.certifai.util.OutputParser;
20 |
21 | /**
22 | * A thorough definition about the idea of Package in java
23 | *
24 | * @author codenamewei
25 | */
26 | public class PackagingIntro
27 | {
28 | static OutputParser out;
29 |
30 | public static void main(String[] args)
31 | {
32 | out = new OutputParser(PackagingIntro.class);
33 |
34 | /**
35 | Enter your code here
36 | Complete the program by making changes to line 38
37 | Tips: change the content assign to variable packageName
38 | **/
39 | String packageName = null;
40 | String output = "Package Name = " + packageName;
41 |
42 | out.evaluate(output);
43 |
44 | out.printResult();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex2/PackagingIntro.md:
--------------------------------------------------------------------------------
1 | # QuickStart!
2 |
3 | **What To Do**
4 | Pass `new PackagingIntro().getClass().getCanonicalName()` to the variable [_packageName_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/basic/ex2/PackagingIntro.java#L38)
5 |
6 |
7 | **Sample Output**
8 | `
9 | Package Name = ai.certifai.basic.ex2.PackagingIntro
10 | `
11 |
12 | **Key Takeaways**
13 | - Basic file directory structure of java project by Apache Maven
14 |
15 |
16 |
17 |
18 | - A few key components to take note of
19 |
20 |
21 |
22 |
23 |
24 | - **Group ID**: Reverse domain name of an organization.
25 | - Group ID contribute to the beginning of packages name
26 |
27 |
28 |
29 |
30 | - **Packages** group related classes, interfaces, and sub-packages.
31 | - Packages are defined all in lower case.
32 | - Packages are period-delimited.
33 | - Essentially, packages are used to prevent conflicts with file names.
34 |
35 |
36 |
37 |
38 | **Quiz**
39 |
40 | 1. What does the keyword **_public_** means?
41 |
42 | 2. What does the word **_static_** means?
43 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex2/metadata/JavaStructure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex2/metadata/JavaStructure.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex2/metadata/JavaStructure_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex2/metadata/JavaStructure_.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex2/metadata/groupID_.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex2/metadata/groupID_.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex2/metadata/packageName.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex2/metadata/packageName.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex3/BluePrint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.basic.ex3;
18 |
19 | import ai.certifai.util.InputParser;
20 | import ai.certifai.util.OutputParser;
21 |
22 | /**
23 | * Introduction to one of the most important concept in Java - class
24 | *
25 | * @author codenamewei
26 | */
27 | class PersonalProfile
28 | {
29 | public String name;
30 |
31 | public int height;
32 | public int weight;
33 |
34 | //constructor
35 | public PersonalProfile(String myName, int myHeight, int myWeight)
36 | {
37 | name = myName;
38 | height = myHeight;
39 | weight = myWeight;
40 | }
41 |
42 | /**
43 | * Enter your code here
44 | */
45 | }
46 |
47 |
48 | public class BluePrint
49 | {
50 | public static void main(String[] args)
51 | {
52 | InputParser in = new InputParser(BluePrint.class);
53 | OutputParser out = new OutputParser(BluePrint.class, in);
54 |
55 | PersonalProfile johnProfile = new PersonalProfile("John Doe", 165, 100);
56 |
57 |
58 | /**
59 | Enter your code here
60 | Complete the program by uncommenting line 59-61 and making accordingly changes in PersonalProfile class
61 | **/
62 | out.evaluate("Name: " + johnProfile.name);
63 | out.evaluate("Height: " + johnProfile.height);
64 | out.evaluate("Width: " + johnProfile.weight);
65 |
66 | out.printResult();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex3/BluePrint.md:
--------------------------------------------------------------------------------
1 | # Construction of Class
2 |
3 | ## **Background**
4 | ### Analogy 1: Cloning
5 |
6 |
7 |
8 |
9 | ### Analogy 2: Create identical items out of the blueprint design
10 |
11 | What is **blueprint**?
12 | Reproduction of technical drawing to allow rapid and accurate production of an unlimited number of copies.
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | **What To Do**
25 | 1. Uncomment 3 lines of code [_from line 59 to 61_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/basic/ex3/BluePrint.java#L59-L61)
26 | 2. Add functions in the class [_PersonalProfile.class_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/basic/ex3/BluePrint.java#L40-L42) to support item 1 to works.
27 |
28 | **Example Code**
29 | ```
30 | public {returning format} {function name}()
31 | {
32 | return {variable name};
33 | }
34 | ```
35 |
36 |
37 | **Expected Output**
38 | ```
39 | Total Number: 1
40 | Name: John Doe
41 | Height: 165
42 | Width: 100
43 | ```
44 |
45 | **Key Takeaways**
46 | - Did you changed the modifier of the variable _name_, _height_, _width_ to make it works?
47 |
48 |
49 |
50 |
51 |
52 | # **Don't do it. Why?**
53 |
54 |
55 |
56 |
57 | The **private** prevent outside entities from access the variables.
58 | You can only deal with the **private** members through getter and setter functions.
59 |
60 | - **void**: Returns no value.
61 |
62 | - There are access modifiers to select on the class, package, function, variables level.
63 |
64 | | Access Modifiers | Function |
65 | | --- | ----------- |
66 | | public | Visible to everywhere. The method / variable can be called from anywhere from outside the program as well. |
67 | | protected | The member can only be accessed by its own class, and subclass of its class in its own package |
68 | | private | The member can only be accessed by own class |
69 |
70 | - **Always** provide variable's name which express it's purpose and meaning clearly.
71 |
72 | ## **Quiz**
73 |
74 | 1. Is .java program equal to machine code?
75 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex3/metadata/cloning.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex3/metadata/cloning.gif
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex3/metadata/public.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex3/metadata/public.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex3/metadata/spaceX.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex3/metadata/spaceX.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex3/metadata/spaceXengine.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex3/metadata/spaceXengine.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex3/metadata/tenor.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex3/metadata/tenor.gif
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex4/JavaTerminology.md:
--------------------------------------------------------------------------------
1 | # Java Key Terminologies
2 |
3 | **What To Do**
4 | 1. Open up your command prompt / terminal
5 |
6 |
7 |
8 |
9 | 2. Type in java command below
10 | ```
11 | java -version
12 | ```
13 | If the output is as shown below, proceed to Step 3.
14 |
15 |
16 |
17 |
18 | If an error message below happens when trying to run _java_ command, go to **Java Debugging Steps** session at the end of this page.
19 |
20 |
21 |
22 |
23 | 3. Run the commands below in the command prompt \
24 | Note: {yourpath} is the absolute path to the folder of java-fundamentals
25 | ```
26 | cd {yourpath}\learn-java-the-certifai-way\java-core\src\main\java
27 | javac ai\certifai\basic\ex4\Run.java
28 | java ai.certifai.basic.ex4.Run 12
29 | ```
30 | **_Note_**: When running a Java application using Java, you supply the classname NOT the bytecode filename.
31 |
32 |
33 |
34 |
35 |
36 | 4. Rerun the last command changing the last value between even and odd numbers
37 | ```
38 | java ai.certifai.basic.ex4.Run {number}
39 | ```
40 |
41 | ## **How To Consider this Exercise Success**
42 | Able to run step 4 from the previous session
43 |
44 |
45 | ## **Key Takeaways**
46 |
47 | **- Java Virtual Machine**
48 | - virtual machine that enables a computer to run Java-based programs
49 |
50 |
51 |
52 |
53 | Installation of Java can come in either of the one flavours
54 | 1. Java Development Kit (JDK)
55 | 2. Java Runtime Environment (JRE)
56 |
57 |
58 | **- Java Development Kit (JDK)**
59 | - Java software development environment including JVM, compiler, debugger and other tools for developing Java applets and applications.
60 |
61 | **- Java Runtime Environment (JRE)**
62 | - A part of programs of JDK
63 | - The JRE creates the JVM and ensures dependencies are available to your Java programs
64 |
65 |
66 |
67 |
68 |
69 | **Java Source Code (.java)**
70 | - Java file contains Java source code
71 |
72 | **Java Bytecode (.class)**
73 |
74 | - Machine language of the Java virtual machine
75 | - Converted from Java source code(.java) to be executable by JVM
76 | - A Java class file(.class) is a file containing Java bytecode that is created by a Java compiler as a result of successful compilation.
77 |
78 |
79 |
80 |
81 |
82 | **Java Debugging Steps**
83 | 1. When java command not found, the cause can be
84 | - Don't have a Java JRE or JDK installed at all.
85 |
86 | **Solution**
87 | Install [Java JDK 8](https://www.oracle.com/pt/java/technologies/javase/javase-jdk8-downloads.html)
88 |
89 | - Did not update the Path Enviroment Variable.
90 |
91 | **Solution**
92 |
93 | 1. Find out where is your java program at. Try _C:\Program Files\Java\java*_ or _C:\Program Files\AdoptOpenJDK\java*_.
94 |
95 |
96 |
97 |
98 | 2. Open up **Edit the system environment variables**.
99 | Add _C:\Program Files\Java\java*\bin_ or _C:\Program Files\AdoptOpenJDK\java*\bin_ to the PATH variable.
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex4/Run.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.basic.ex4;
18 |
19 | /**
20 | * Basic Java File to test run with terminal / command prompt
21 | *
22 | * @author codenamewei
23 | */
24 | public class Run
25 | {
26 | public static void main(String[] args)
27 | {
28 | if(args.length == 1)
29 | {
30 | try
31 | {
32 | int value = Integer.parseInt(args[0]);
33 |
34 | if(value % 2 == 0)
35 | {
36 | System.out.println("Even number");
37 | }
38 | else
39 | {
40 | System.out.println("Odd number");
41 | }
42 | }catch(Exception e)
43 | {
44 | System.out.println("Argument parse integer failed: " + e);
45 | }
46 |
47 | }
48 | else
49 | {
50 | System.out.println("There should be one input");
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex4/metadata/commandprompt.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex4/metadata/commandprompt.PNG
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex4/metadata/environment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex4/metadata/environment.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex4/metadata/java.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex4/metadata/java.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex4/metadata/javacommand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex4/metadata/javacommand.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex4/metadata/javacommanderror.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex4/metadata/javacommanderror.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex4/metadata/javaenvironmentpath.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex4/metadata/javaenvironmentpath.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex4/metadata/javaterm.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex4/metadata/javaterm.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex4/metadata/javaterm1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex4/metadata/javaterm1.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex4/metadata/jvm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex4/metadata/jvm.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex4/metadata/output.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex4/metadata/output.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex5/If_ElseIf_Else.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.basic.ex5;
18 |
19 | import ai.certifai.util.InputParser;
20 | import ai.certifai.util.OutputParser;
21 |
22 | /**
23 | * If - Else If - Else Loop
24 | *
25 | * @author codenamewei
26 | */
27 | public class If_ElseIf_Else
28 | {
29 | static OutputParser out;
30 | static InputParser in;
31 |
32 | public static void main(String[] args)
33 | {
34 | in = new InputParser(If_ElseIf_Else.class);
35 | out = new OutputParser(If_ElseIf_Else.class, in);
36 |
37 | int totalUseCases = in.getTotalUseCases();
38 |
39 | for(int i = 0; i < totalUseCases; ++i)
40 | {
41 | int input = in.getIntegerInput();
42 |
43 | System.out.println(input);
44 | String output = compute(input);
45 |
46 | out.evaluate(output);
47 | }
48 |
49 | out.printResult();
50 | }
51 |
52 | public static String compute(int input)
53 | {
54 | /**
55 | Enter your code here to complete this function
56 | Uncomment placeholder line 56 when done
57 | **/
58 | return "";
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex5/If_ElseIf_Else.md:
--------------------------------------------------------------------------------
1 | # If - Else if - Else loop
2 |
3 | ## **What To Do**
4 | Fill in function [_String compute(int input)_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/basic/ex5/If_ElseIf_Else.java#L50-L57) to fulfill the conditions above
5 |
6 | Given an integer, _input_, return an output string of **Even**, **Odd**, **Out Of Range**, **Special**
7 | git add
8 | - if _input_ more or equal to 50 but less or equal to 100, return **Special**
9 | - if _input_ greater than 10000, return **Out of Range**
10 |
11 | ```
12 | if(condition 1)
13 | {
14 | //code block
15 | }
16 | else if(condition 2)
17 | {
18 | //code block
19 | }
20 | else if(condition 3)
21 | {
22 | //code block
23 | }
24 | else
25 | {
26 | //code block
27 | }
28 | ```
29 |
30 | ## **Sample Input**
31 | 1
32 |
33 | ## **Sample Output**
34 | `
35 | Odd
36 | `
37 |
38 | ## **Key Takeaways**
39 |
40 | - How to build if-elseif-else loop
41 |
42 | ## **Quiz**
43 |
44 | 1. How to do if-else loop in one line code?
45 | 2. What is the differences between operator OR (|) and operator logical-OR (||)?\
46 | Likewise for operator AND (&) and operator logical-AND (&&)
47 | ```
48 | if((condition 1) | (condition 2))
49 | {
50 | //code block
51 | }
52 | else if((condition 1) || (condition 2))
53 | {
54 | //code block
55 | }
56 | else
57 | {
58 | //code block
59 | }
60 | ```
61 |
62 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex6/DataTypes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.basic.ex6;
18 |
19 | import ai.certifai.util.InputParser;
20 | import ai.certifai.util.OutputParser;
21 |
22 | /**
23 | * Data Types
24 | *
25 | * @author codenamewei
26 | */
27 | public class DataTypes
28 | {
29 | static OutputParser out;
30 | static InputParser in;
31 |
32 | public static void main(String[] args)
33 | {
34 | in = new InputParser(DataTypes.class);
35 | out = new OutputParser(DataTypes.class, in);
36 |
37 | /**
38 | Enter your code here
39 | Tips: out.evaluate({content}) has to be used for the program to be success
40 | **/
41 |
42 | out.printResult();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex6/DataTypes.md:
--------------------------------------------------------------------------------
1 | # Types of Data
2 |
3 | ## **What To Do**
4 | Define these 4 values in the respective data format and get it evaluated
5 |
6 | - "Nasi Lemak!" as **String**
7 | - 20 as **int**
8 | - 100.054 as **float**
9 | - true as **boolean**
10 |
11 | Fill in the code in [this range](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/basic/ex6/DataTypes.java#L36-L39)
12 |
13 | ## **Sample Input**
14 |
15 | ```
16 | int value = 2;
17 | out.evaluate(value);
18 | ```
19 |
20 | ## **Key Takeaways**
21 |
22 | - Different primitive data types in Java:
23 | - int
24 | - double
25 | - String
26 | - boolean
27 |
28 | - There's wrapper for all these primitive data types.
29 | On a general note: these wrapper class wrap a primitive type into an object.
30 | Subsequently, providing more flexibility in storing and manipulating the data.
31 |
32 | | Primitive Data Type | Object |
33 | | --- | ----------- |
34 | | int | Integer |
35 | | double | Double |
36 | | float | Float |
37 | | boolean | Boolean |
38 |
39 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex7/ForLoop.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.basic.ex7;
18 |
19 | import ai.certifai.util.InputParser;
20 | import ai.certifai.util.OutputParser;
21 |
22 | /**
23 | * For Loop
24 | *
25 | * @author codenamewei
26 | */
27 | public class ForLoop
28 | {
29 | static OutputParser out;
30 | static InputParser in;
31 |
32 | public static void main(String[] args)
33 | {
34 | in = new InputParser(ForLoop.class);
35 | out = new OutputParser(ForLoop.class, in);
36 |
37 | int totalUseCases = in.getTotalUseCases();
38 |
39 | for(int i = 0; i < totalUseCases; ++i)
40 | {
41 | int linesPerUseCase = in.getCurrentUseCaseTotalLines();
42 |
43 | /**
44 | * Enter your code here
45 | * Tips: out.evaluate({content}) has to be used to pass the program
46 | */
47 | }
48 |
49 | out.printResult();
50 |
51 | }
52 | }
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex7/ForLoop.md:
--------------------------------------------------------------------------------
1 | # For Loop
2 | For loop is a very important implementation in most programming.
3 |
4 |
5 |
6 |
7 |
8 | ## **What To Do**
9 | Variable [**linesPerUseCase**](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/basic/ex7/ForLoop.java#L40) defines how many lines per use case. \
10 | Use a **for loop** to get string input of each line. **Tips: _in.getStringInput()_** \
11 | and get it evaluated by passing to _**out.evaluate(~~)**_.
12 |
13 | ## **Sample Input**
14 | ```
15 | 3
16 | hello world
17 | Big screen
18 | Game OfThronews
19 | ```
20 |
21 | ## **Sample Output**
22 | ```
23 | hello world
24 | Big screen
25 | Game OfThronews
26 | ```
27 |
28 | ## **Key Takeaways**
29 | - Mastering for-loop is very important for effective use of Java
30 |
31 | - Nested for-loop is very common for complex use case.
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex7/metadata/forLoop.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex7/metadata/forLoop.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/basic/ex7/metadata/nestedloop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/basic/ex7/metadata/nestedloop.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex10/ExceptionHandling.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.intermediate.ex10;
18 |
19 | import ai.certifai.util.OutputParser;
20 |
21 | import java.io.File;
22 | import java.util.Scanner;
23 |
24 | /**
25 | * Exception Handling
26 | *
27 | * @author codenamewei
28 | */
29 | public class ExceptionHandling
30 | {
31 | public static void main(String[] args) throws Exception
32 | {
33 | OutputParser out = new OutputParser(ExceptionHandling.class);
34 |
35 | out.evaluate(readFile());
36 | out.evaluate(divideByZero());
37 | out.evaluate(retrieveObject());
38 |
39 | out.printResult();
40 | }
41 |
42 | private static String readFile() throws Exception
43 | {
44 | String filePathInString = "metadata/sample.txt"; //FILE DID NOT EXIST
45 |
46 | //Rewrite the statement below onwards to catch the exception with try-catch-finally
47 | File filePath = new File(filePathInString);
48 | Scanner input = new Scanner(filePath);
49 | return "";
50 | }
51 |
52 | private static String divideByZero() throws Exception
53 | {
54 | int value = 1000 / 0;
55 |
56 | return "";
57 | }
58 |
59 | private static String retrieveObject() throws Exception
60 | {
61 | String buffer = null;
62 |
63 | buffer.length();
64 |
65 | return "";
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex10/ExceptionHandling.md:
--------------------------------------------------------------------------------
1 | # Exception Handling
2 |
3 | There's two types of errors in general in programming.
4 | - compile time error
5 | - runtime error (errors and exceptions)
6 |
7 | Exception handling in Java is designed to handle the **runtime exceptions**
8 | so that the normal flow of the application can be maintained.
9 |
10 | For example:
11 | Having code blocks below
12 |
13 | ```$xslt
14 | public class HelloWorld
15 | {
16 | public static void main(String args)
17 | {
18 | line 1 statement;
19 |
20 | line 2 statement; //RUNTIME ERRORS OCCUR!
21 | line 3 statement;
22 |
23 | line 4 statement;
24 | line 5 statement;
25 |
26 | }
27 | }
28 | ```
29 |
30 |
31 |
32 |
33 |
34 | If exception happens on statement 2, the rest of the code will not be executed.
35 | Reason being is the scenario will be ill-defined and the results will not be in the range of expectation.
36 |
37 | ### try - catch - finally
38 |
39 | Exception is written in this way in general.
40 |
41 | ```$xslt
42 | try
43 | {
44 | //statement
45 | }
46 | catch(Exception e)
47 | {
48 | //statement
49 | }
50 | finally
51 | {
52 | //statement
53 | }
54 | ```
55 | ## **What To Do**
56 |
57 | Rewrite the function block
58 | - [_readFile()_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/intermediate/ex10/ExceptionHandling.java#L41)
59 | - [_divideByZero()_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/intermediate/ex10/ExceptionHandling.java#L51)
60 | - [_retrieveObject()_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/intermediate/ex10/ExceptionHandling.java#L58)
61 | to catch Exception
62 | **Tips:** return e.getClass().getCanonicalName() for each function block for program to successfully execute
63 |
64 |
65 | ## **Sample Input**
66 |
67 | ```
68 | int value = 1000 / 0;
69 | ```
70 |
71 | ## **Sample Output**
72 |
73 | ```
74 | java.lang.ArithmeticException
75 | ```
76 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex10/metadata/exception.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex10/metadata/exception.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex11/WhileLoop.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.intermediate.ex11;
18 |
19 | import ai.certifai.util.FileLoader;
20 | import ai.certifai.util.InputParser;
21 | import ai.certifai.util.OutputParser;
22 |
23 | import java.io.BufferedReader;
24 | import java.io.File;
25 | import java.io.FileReader;
26 |
27 | /**
28 | * While Loop
29 | *
30 | * @author codenamewei
31 | */
32 | public class WhileLoop
33 | {
34 | static OutputParser out;
35 | static InputParser in;
36 |
37 | public static void main(String[] args) throws Exception
38 | {
39 | in = new InputParser(WhileLoop.class);
40 | out = new OutputParser(WhileLoop.class, in);
41 |
42 | int totalUseCases = in.getTotalUseCases();
43 |
44 | for(int i = 0; i < totalUseCases; ++i)
45 | {
46 | String inputFileName = in.getStringInput();
47 |
48 | File inputFilePath = new FileLoader().getInputLoader(WhileLoop.class, inputFileName);
49 |
50 | out.evaluate(getTotalNumberOfLines(inputFilePath));
51 | }
52 |
53 | out.printResult();
54 | }
55 |
56 | private static int getTotalNumberOfLines(File inputFile) throws Exception
57 | {
58 | BufferedReader reader = new BufferedReader(new FileReader(inputFile));
59 |
60 | /**
61 | Modify your code in this function
62 | Change the return value to get the success of the program
63 | **/
64 | return 0;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex11/WhileLoop.md:
--------------------------------------------------------------------------------
1 | # While Loop
2 |
3 | While loop repeatedly executes a target statement as long as a given condition is true.
4 |
5 |
6 |
7 |
8 |
9 | ## **What To Do**
10 | This program (specifically BufferedReader) reads in content from specific input file.
11 | There's no way of knowing how many times to loop through the BufferedReader to get total number of lines beforehand.
12 |
13 | A while loop has to be used to iterate through **BufferedReader reader** to get next lines if next line exist.
14 |
15 | The function _getTotalNumberOfLines_ takes in a File and return total number of lines of the specific file.
16 |
17 | Fill in function [_private static void _getTotalNumberOfLines_(File inputFile) throws Exception_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/intermediate/ex11/WhileLoop.java#L58-L62).
18 |
19 | **Tips:**
20 | - Use **_reader.readLine()_** to read from file
21 | - If there is no next line, **_reader.readLine()_** will return null;
22 | - Change line 63 to return number of lines in the specific file.
23 |
24 | ## **Sample Input**
25 | With input file of
26 |
27 |
28 |
29 |
30 | ## **Sample Output**
31 | 7
32 |
33 | ## **Above and Beyond**
34 | - Check out the variant of a while loop - **Do-While loop**
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex11/metadata/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex11/metadata/2.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex11/metadata/Capture.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex11/metadata/Capture.JPG
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex11/metadata/dowhileloop.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex11/metadata/dowhileloop.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex11/metadata/whileloop.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex11/metadata/whileloop.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex12/MapImp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.intermediate.ex12;
18 |
19 | import ai.certifai.util.Conversion;
20 | import ai.certifai.util.InputParser;
21 | import ai.certifai.util.OutputParser;
22 | import lombok.NonNull;
23 |
24 | import java.util.HashMap;
25 | import java.util.List;
26 | import java.util.Map;
27 |
28 | /**
29 | * Map Loop
30 | *
31 | * @author codenamewei
32 | */
33 | public class MapImp
34 | {
35 | static OutputParser out;
36 | static InputParser in;
37 | static final String GET = "get";
38 | static final String DELETE = "delete";
39 | static final String ADD = "add";
40 |
41 | public static void main(String[] args) throws Exception
42 | {
43 | in = new InputParser(MapImp.class);
44 | out = new OutputParser(MapImp.class, in);
45 |
46 | Map keyValue = new HashMap();
47 |
48 | initKeyValue(keyValue);
49 |
50 | int totalUseCases = in.getTotalUseCases();
51 |
52 | for(int i = 0; i < totalUseCases; ++i)
53 | {
54 | String line = in.getStringInput();
55 |
56 | List arrayInput = Conversion.StringToListString(line);
57 |
58 | if(arrayInput.size() == 3)
59 | {
60 | configKeyValue(keyValue, arrayInput.get(0), arrayInput.get(1), arrayInput.get(2));
61 | }
62 | else if(arrayInput.size() == 2)
63 | {
64 | configKeyValue(keyValue, arrayInput.get(0), arrayInput.get(1), null);
65 | }
66 | else
67 | {
68 | throw new Exception("Array size not fall under expectation. Program not expected to work fine");
69 | }
70 | }
71 |
72 | out.printResult();
73 | }
74 |
75 |
76 | private static void configKeyValue(@NonNull Map keyValue, @NonNull String action, @NonNull String country, String phoneCode) {
77 |
78 | /**
79 | Modify your code in this function
80 | Do the accordingly changes to this function to reach the successful run of the code
81 | Tips: out.evaluate({content}) has to be used for the program to be success
82 | **/
83 |
84 | }
85 |
86 | private static void initKeyValue(Map keyValue)
87 | {
88 | keyValue.put("Italy", "39");
89 | keyValue.put("Malaysia", "60");
90 | keyValue.put("Indonesia", "62");
91 | keyValue.put("Singapore", "65");
92 | keyValue.put("China", "86");
93 | keyValue.put("Russia", "7");
94 |
95 | }
96 | }
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex12/MapImp.md:
--------------------------------------------------------------------------------
1 | # Map <> HashMap
2 | A Map is an object that maps keys to values.
3 |
4 |
5 |
6 |
7 |
8 | In program MapImp, Map<>HashMap is implemented to store country name as key and country code as value.
9 |
10 |
11 |
12 |
13 | **When do we use Map<>HashMap** \
14 | Maps are used for when you want to associate a key with a value and Lists are an ordered collection.
15 |
16 | **Example Scenario:**
17 | - Item names matching with products
18 |
19 |
20 |
21 |
22 | - User IDs matching with names
23 |
24 |
25 |
26 |
27 | ## **What To Do**
28 | Given a Map of Country Name and Country Code
29 |
30 | ```
31 | Italy: 39
32 | Malaysia: 60
33 | Indonesia: 62
34 | Singapore: 65
35 | China: 86
36 | Russia: 7
37 | ```
38 |
39 | Input comes in the form of
40 |
41 | - GET country_name
42 | - If country_name key exist, write **out.evaluate({get the country code})**, else write **out.evaluate("False")** \
43 |
44 | - DELETE country_name
45 | - If DELETE an existing key, write **out.evaluate("True")**, else write **out.evaluate("False")** \
46 |
47 | - ADD country_name country_code
48 | - If ADD a key which is not exist in the Map<>HashMap, write **out.evaluate("True")** and put the key & value exist in **Map keyValue*
49 | - Else, write **out.evaluate("False")**
50 |
51 | **Only make changes to the function [_configKeyValue(...)_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/intermediate/ex12/MapImp.java#L77-L81)**
52 |
53 | ## **Sample Input**
54 | get Malaysia
55 | delete Malaysia
56 | delete Malaysia
57 | add Singapore 65
58 |
59 | ## **Sample Output**
60 | 60
61 | True
62 | False
63 | True
64 |
65 | ## **Key Takeaways**
66 |
67 | **Properties of Map:**
68 | - Unique Key. There should not be duplicates key.
69 | - Keys should be all belongs to one type of Object. Likewise for values.
70 | - Example
71 | - Map keyValue = new HashMap();
72 | - Map countryCode = new HashMap();
73 | - Map method = new HashMap();
74 |
75 | - Not an ordered collection. Does not return keys and values in the same order they have been inserted.
76 |
77 |
78 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex12/metadata/country_code.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex12/metadata/country_code.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex12/metadata/key-value.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex12/metadata/key-value.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex12/metadata/key-value2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex12/metadata/key-value2.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex12/metadata/receipt.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex12/metadata/receipt.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex13/SubString.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.intermediate.ex13;
18 |
19 | import ai.certifai.util.InputParser;
20 | import ai.certifai.util.OutputParser;
21 |
22 | /**
23 | * SubString
24 | *
25 | * @author codenamewei
26 | */
27 | public class SubString
28 | {
29 | static OutputParser out;
30 | static InputParser in;
31 |
32 | static final String FAIL_MESSAGE = "It's not a file!";
33 |
34 | public static void main(String[] args)
35 | {
36 | in = new InputParser(SubString.class);
37 | out = new OutputParser(SubString.class, in);
38 |
39 | int totalUseCases = in.getTotalUseCases();
40 |
41 | for(int i = 0; i < totalUseCases; ++i)
42 | {
43 | String input = in.getStringInput();
44 |
45 | out.evaluate(getExtensionIfExist(input));
46 | }
47 |
48 | out.printResult();
49 | }
50 |
51 | private static String getExtensionIfExist(String input)
52 | {
53 | /**
54 | Modify your code in this function
55 | Do the accordingly changes to this function to reach the successful run of the code
56 | Change the returning value in line 57
57 | **/
58 | return null;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex13/SubString.md:
--------------------------------------------------------------------------------
1 | # Manipulation of String
2 |
3 | Getting a substring of a string is a very common operation to perform
4 |
5 |
6 |
7 |
8 | ## **What To Do**
9 | With each string input, return the file formats if exist
10 |
11 |
12 |
13 |
14 | ### Note:
15 | - Only get the extension name without the dot '.'
16 | - If the corresponding input is a string without file extension format, return **It's not a file!**
17 |
18 | Modify the function [_getExtensionIfExist_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/intermediate/ex13/SubString.java#L50-L57) and the returning value of it
19 |
20 | ## **Sample Input**
21 | Example.pdf\
22 | SampleFolder
23 |
24 | ## **Sample Output**
25 | pdf\
26 | It's not a file!
27 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex13/metadata/ref.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex13/metadata/ref.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex13/metadata/substring.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex13/metadata/substring.JPG
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex14/AdvancedSubString.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.intermediate.ex14;
18 |
19 | import ai.certifai.util.InputParser;
20 | import ai.certifai.util.OutputParser;
21 |
22 | /**
23 | * SubString
24 | *
25 | * @author codenamewei
26 | */
27 | public class AdvancedSubString
28 | {
29 | static OutputParser out;
30 | static InputParser in;
31 |
32 | public static void main(String[] args)
33 | {
34 | in = new InputParser(AdvancedSubString.class);
35 | out = new OutputParser(AdvancedSubString.class, in);
36 |
37 | int totalUseCases = in.getTotalUseCases();
38 |
39 | for(int i = 0; i < totalUseCases; ++i)
40 | {
41 | String input = in.getStringInput();
42 |
43 | out.evaluate(processString(input));
44 | }
45 |
46 | out.printResult();
47 | }
48 |
49 | private static String processString(String input)
50 | {
51 | /**
52 | Modify your code in this function
53 | Do the accordingly changes to this function to reach the successful run of the code
54 | Change the returning value in line 55
55 | */
56 | return null;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex14/AdvancedSubString.md:
--------------------------------------------------------------------------------
1 | # Advanced Manipulation of String
2 |
3 | Lets build on the previous exercises to carry on a more complicated operations for string handling.
4 |
5 | ## **What To Do**
6 | With each string input, perform the following operations and return the string
7 | - Remove the file extension if any
8 | - Remove the spaces in the beginning and end of string (**Tips:** use string.trim())
9 | - Replace spaces in between letters with underscore (_)
10 |
11 |
12 |
13 |
14 |
15 |
16 | Modify function [_processString_](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/intermediate/ex14/AdvancedSubString.java#L50-55) and change the returning result in line 55
17 |
18 | ## **Sample Input**
19 | Example.pdf\
20 | Sample Folder
21 |
22 | ## **Sample Output**
23 | Example\
24 | Sample_Folder
25 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex14/metadata/sample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex14/metadata/sample.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex15/QuickSortImp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.intermediate.ex15;
18 |
19 | import ai.certifai.util.Conversion;
20 | import ai.certifai.util.InputParser;
21 | import ai.certifai.util.OutputParser;
22 |
23 | import java.util.List;
24 |
25 | class QuickSort
26 | {
27 | /**
28 | Modify your code in this class
29 | Do the accordingly changes to reach the successful run of the code
30 | **/
31 |
32 | public List sort(List array, int beginIndex, int endIndex)
33 | {
34 |
35 | return null;
36 | }
37 | }
38 |
39 | /**
40 | Quick Sort
41 | *
42 | @author codenamewei
43 | */
44 | public class QuickSortImp
45 | {
46 | static OutputParser out;
47 | static InputParser in;
48 |
49 | public static void main(String[] args)
50 | {
51 | in = new InputParser(QuickSortImp.class);
52 | out = new OutputParser(QuickSortImp.class, in);
53 |
54 | int totalUseCases = in.getTotalUseCases();
55 |
56 | for(int i = 0; i < totalUseCases; ++i)
57 | {
58 | String line = in.getStringInput();
59 |
60 | List arrayInput = Conversion.StringToListInteger(line);
61 |
62 | List arrayOutput = new QuickSort().sort(arrayInput, 0, arrayInput.size() - 1);
63 |
64 | out.evaluate(Conversion.ListIntegerToString(arrayOutput));
65 |
66 | }
67 | out.printResult();
68 |
69 | }
70 | }
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex15/QuickSortImp.md:
--------------------------------------------------------------------------------
1 | # Quick Sort
2 |
3 | Quick sort is a highly efficient sorting algorithm and is based on partitioning of array of data into smaller arrays.
4 |
5 |
6 |
7 |
8 |
9 | The quicksort algorithm choose a pivot point, and partitioning the collection around the pivot, so that elements smaller than the pivot are before it, and elements larger than the pivot are after it
10 |
11 | The pivot can be
12 | - the first element in the array
13 | - the last element in the array
14 | - an element of a random index
15 |
16 | ## **What To Do**
17 |
18 | Modify class [**_QuickSort_**](https://github.com/CertifaiAI/learn-java-the-certifai-way/blob/master/java-core/src/main/java/ai/certifai/intermediate/ex15/QuickSortImp.java#L24-L36) to perform the quick sort algorithm.
19 | The returninng **_List_** of the function **_sort_** should be an increasing order array.
20 |
21 | ## **Sample Input**
22 | 2 6 3 17 12
23 |
24 | ## **Sample Output**
25 | 2 3 6 12 17
26 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex15/metadata/sort.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex15/metadata/sort.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex8/OrderedCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.intermediate.ex8;
18 |
19 | import ai.certifai.util.Conversion;
20 | import ai.certifai.util.InputParser;
21 | import ai.certifai.util.OutputParser;
22 |
23 | import java.util.List;
24 |
25 | /**
26 | * List ArrayList
27 | *
28 | * @author codenamewei
29 | */
30 | public class OrderedCollection
31 | {
32 | static OutputParser out;
33 | static InputParser in;
34 |
35 | public static void main(String[] args)
36 | {
37 | in = new InputParser(OrderedCollection.class);
38 | out = new OutputParser(OrderedCollection.class, in);
39 |
40 | int totalUseCases = in.getTotalUseCases();
41 |
42 | for(int i = 0; i < totalUseCases; ++i)
43 | {
44 | String line = in.getStringInput();
45 |
46 | List arrayInput = Conversion.StringToListInteger(line);
47 |
48 | iterate(arrayInput);
49 | }
50 |
51 | out.printResult();
52 | }
53 |
54 | public static void iterate(List array)
55 | {
56 | /**
57 | Enter your code in this function
58 | Tips: out.evaluate({content}) has to be used for the program to be success
59 | **/
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex8/OrderedCollection.md:
--------------------------------------------------------------------------------
1 | # List<>ArrayList
2 | List interface with ArrayList class create a dynamic array that contains objects.
3 |
4 |
5 |
6 |
7 |
8 | In lament terms, a **List<>ArrayList** is a specified container that store values. \
9 | The values in a single container has to be the same type. \
10 | Example:
11 | - an array of integers
12 | - an array of floating values
13 | - an array of string
14 |
15 |
16 |
17 |
18 |
19 | ## **What To Do**
20 | Iterate over an array of integers given in the function. Modify the _iterate(...)_ function
21 | ```
22 | public static void iterate(List array)
23 | {
24 | /**
25 | Enter your code in this function
26 | Tips: out.evaluate({content}) has to be used for the program to be success
27 | **/
28 | }
29 | ```
30 | **Tips: Search for _iterate through a java list_ on any web searching browser**
31 |
32 |
33 | ## **Sample Input**
34 | ```
35 | 1
36 | 1 2 3 4 5
37 | ```
38 |
39 | ## **Sample Output**
40 | ```
41 | 1
42 | 2
43 | 3
44 | 4
45 | 5
46 | ```
47 |
48 | ## **Key Takeaways**
49 | - **List<>ArrayList** declaration is compulsory to use Object rather than primitive data types.
50 |
51 | | Primitive Data Type | Object |
52 | | --- | ----------- |
53 | | int | Integer |
54 | | double | Double |
55 | | float | Float |
56 | | boolean | Boolean |
57 |
58 | - List<>ArrayList is a dynamic collection of elements. All elements in the same collection have the same types.
59 |
60 | ## **Above and Beyond**
61 | - How to remove a specified item from an arraylist?
62 |
63 | - How to add another arraylist storing the same type of values?
64 |
65 | - How to replace a value in a specified index of an arraylist?
66 |
67 | - How to get the total sizes of an arraylist?
68 |
69 | - What's the differences between arraylist(List) and a classic array of values (int[]) ?
70 |
71 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex8/metadata/array.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex8/metadata/array.JPG
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex8/metadata/container.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex8/metadata/container.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex9/AdvancedForLoop.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.intermediate.ex9;
18 |
19 | import ai.certifai.util.Conversion;
20 | import ai.certifai.util.InputParser;
21 | import ai.certifai.util.OutputParser;
22 |
23 | import java.util.List;
24 |
25 | /**
26 | * Advanced For Loop
27 | *
28 | * @author codenamewei
29 | */
30 | public class AdvancedForLoop
31 | {
32 | static OutputParser out;
33 | static InputParser in;
34 |
35 | public static void main(String[] args)
36 | {
37 | in = new InputParser(AdvancedForLoop.class);
38 | out = new OutputParser(AdvancedForLoop.class, in);
39 |
40 | int totalUseCases = in.getTotalUseCases();
41 |
42 | for(int i = 0; i < totalUseCases; ++i)
43 | {
44 | String line = in.getStringInput();
45 |
46 | List arrayInput = Conversion.StringToListInteger(line);
47 |
48 | int m = arrayInput.get(0);
49 | int n = arrayInput.get(1);
50 | int b = arrayInput.get(2);
51 |
52 | assessArrayValue(m, n, b);
53 | }
54 |
55 | out.printResult();
56 | }
57 |
58 | ////a_m = a_(m - 1) + 2^(n + m) + b
59 | public static void assessArrayValue(int m, int n, int b)
60 | {
61 | List array = null;
62 | /**
63 | Modify your code in this function
64 | Do the accordingly changes to this function to reach the successful run of the code
65 | **/
66 |
67 | String output = Conversion.ListIntegerToString(array);
68 |
69 | out.evaluate(output);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex9/AdvancedForLoop.md:
--------------------------------------------------------------------------------
1 | # Advanced For Loop
2 | Now after you learned about For-Loop and List<>ArrayList. \
3 | Let's combine these two for an interesting challenge.
4 |
5 | ## **What To Do**
6 |
7 | Input text file will be presented in the form below
8 | - Sample Input File
9 |
10 | For variable **_m, n, b_**, produce output in the form below
11 |
12 |
13 |
14 |
15 | Each value _a_ is calculated with the formula of
16 |
17 |
18 |
19 |
20 |
21 | **Note: asmaller than 0 = 0, always**
22 |
23 | ## **Condition:**
24 | - **_m >= 1_**
25 | - **_n >= 0_**
26 | - **_b >= 0_**
27 |
28 | Iterate over an array of integers given in the function. Modify the _assessArrayValue(...)_ function
29 |
30 |
31 |
32 |
33 | ## **Sample Input**
34 | 2 2 3 \
35 | Note: m = 2, n = 2, b = 3
36 |
37 | ## **Sample Output**
38 | 7 18
39 |
40 |
41 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex9/metadata/0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex9/metadata/0.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex9/metadata/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex9/metadata/1.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/intermediate/ex9/metadata/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/intermediate/ex9/metadata/2.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/RunMaven.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.maven;
18 |
19 | import ai.certifai.util.PathHandler;
20 |
21 | /**
22 | * Maven
23 | *
24 | * @author codenamewei
25 | */
26 | public class RunMaven {
27 | public static void main(String[]args)
28 | {
29 | /*
30 | //TODO: Change this into your own image path
31 | String sourceImagePath = "C:\\Users\\chiaw\\Desktop\\images\\chip\\70.jpg";
32 |
33 | //Check image validity
34 | if(PathHandler.isFileValid(sourceImagePath) == false)
35 | {
36 | System.out.println("Program abort. ");
37 | return;
38 | }
39 |
40 | //Read in image
41 | Mat opencvMat = imread(sourceImagePath);
42 | int w = opencvMat.cols();
43 | int h = opencvMat.rows();
44 | int depth = opencvMat.depth();
45 |
46 | if(depth == 1)
47 | {
48 | System.out.println("Image already is grayscale. Program abort");
49 | return;
50 | }
51 |
52 | //Create output Mat to store grayscale image
53 | Mat outputImage = new Mat();
54 |
55 | //Convert the image to grayscale
56 | cvtColor(opencvMat, outputImage, COLOR_RGB2GRAY);
57 |
58 | //Save output image as file
59 | String outputPath = PathHandler.getPathToFile(sourceImagePath) + "_grayscale.png";
60 | imwrite(outputPath, outputImage);
61 | System.out.println("The image is successfully to Grayscale");
62 |
63 |
64 | imshow("Color Image", opencvMat);
65 | imshow("Grayscale Image", outputImage);
66 |
67 | //Press "Esc" to close window
68 | if (waitKey(0) == 27) destroyAllWindows();
69 | */
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/RunMaven.md:
--------------------------------------------------------------------------------
1 | # Gist of Java with Apache Maven
2 |
3 | ## Chapter 1 Introduction of Apache Maven
4 |
5 | ### 1.1 Installation of Apache Maven :man_technologist: :woman_technologist:
6 |
7 | - Download and install Apache Maven from [here](https://maven.apache.org/download.cgi).
8 |
9 | - Verify the installation through
10 | ```
11 | mvn -version
12 | ```
13 |
14 |
15 |
16 |
17 | ### 1.2 What is Apache Maven
18 |
19 | - Apache Maven is a **project management tool** primarily for Java projects.
20 |
21 | - Apache Maven manage a project's build, reporting and documentation from a central piece of information, pom.xml - project object model (POM).
22 |
23 | - This folder covers some of the Maven essentials to manage Java based project in day to day use.
24 |
25 | ### 1.3 Build an Apache Maven Project :man_technologist: :woman_technologist:
26 |
27 | Step 1: Create a new project in Intellij
28 |
29 | - There's two approaches in creating new project.
30 | First of all, open Intellij in your host system.
31 |
32 | 1. (Option 1) Click "Create New Project" in the "Welcome to IntelliJ IDEA" interface.
33 |
34 |
35 |
36 |
37 | 1. (Option 2) If there's an existing project opened, create a new project by going to **File -> New -> Project**
38 |
39 |
40 |
41 |
42 | 2. Choose the archetype **maven-archetype-quickstart** to start with.
43 | :information_source: maven-archetype-quickstart is sample Maven template which provides skeleton structure of Java project.
44 |
45 |
46 |
47 |
48 | 3. Fill up the bottom fields accordingly.
49 |
50 | - **Name**: Name of Project
51 | - Example:
52 | - Name: MyFirstJavaProject
53 | - **Location**: Directory where the project will be created
54 | - Example:
55 | - Location: ~/Desktop/TEMP/MyFirstDL4JProject
56 | - **GroupId**: Reverse domain name of the organization. The purpose of GroupId is to makes the project recognizable across all available projects.
57 | - Example:
58 | - GroupID: ai.certifai
59 | - **ArtifactId**: Name of Artifact. By default same with the name of the project
60 | - Example:
61 | - Name: MyFirstJavaProject
62 | - **Version**: Version of the project. Default value is 1.0-SNAPSHOT
63 | - Example:
64 | - Version: 1.0-SNAPSHOT
65 |
66 |
67 |
68 |
69 |
70 | :information_source: These information can be modified at later phase.
71 |
72 | :information_source: The properties of the project can be double checked in this interface during creating project.
73 |
74 |
75 |
76 |
77 |
78 | ## Chapter 2 Dive in Java with Apache Maven
79 |
80 | - The fundamental component to manage dependencies is by using **pom.xml - project object model (POM)**.
81 | - Simply put, _pom.xml_ is an XML representation of a Maven project with default values of configurations for dependencies name, version and etc.
82 |
83 | ### 2.1 Single-Module Java Project
84 |
85 | - Note:
86 | A module in Java represents a group of closely related packages and resources.
87 |
88 | - With pom.xml, dependency management is easy in defining, creating and maintaining reproducible environments with well-defined classpaths and library versions.
89 |
90 |
91 |
92 |
93 |
94 | - Let's take a look at a bare bone pom.xml.
95 |
96 |
97 |
98 |
99 |
100 |
101 | ### 2.2 Maven Central Repository
102 |
103 | - Maven Central Repository hosted on the cloud.
104 |
105 |
106 |
107 |
108 |
109 | - Maven contains a huge number of commonly used libraries to be used by the community.
110 | - A library in Java is represented as a jar package.
111 |
112 |
113 |
114 |
115 |
116 | ### 2.3 Add dependencies to _my-first-dl4j-project_ :man_technologist: :woman_technologist:
117 |
118 | 1. Search for javacv-platform in [central repository](https://mvnrepository.com/repos/central)
119 |
128 |
129 | - Click into the version desired
130 |
131 |
132 |
133 |
134 |
135 | 2. Copy the code snippet under the _dependencies_ of pom.xml.
136 |
137 |
138 |
139 |
140 | Paste the code snippets in the root pom.xml of your newly build project.
141 |
142 |
143 |
144 |
145 |
146 | 3. Paste these code snippets in the [**App.java**](https://gist.github.com/codenamewei/4bfe8251c2ddfb0e84db2dc3f5a37c9c)
147 |
148 | 4. Reload project
149 |
150 |
151 |
152 | - You can check the folder _.m2_ that the corresponding jar file has been downloaded from central repository.
153 |
154 |
155 |
156 |
157 |
158 | 5. Run the program
159 |
160 | ### How does **2.3** works?
161 |
162 | _.m2_ folder in the host system saved local repositories.
163 | If a particular dependency not found in the folder, Maven would check _.m2_ folder to make sure all dependencies exists locally.
164 | Else, Apache Maven would download the dependency from the cloud by referring to pom.xml.
165 |
166 |
167 |
168 |
169 |
170 | ### 2.4 Multi-Modules Project :man_technologist: :woman_technologist:
171 |
172 | - Multi modules project is more complex compared to single module project.
173 | - There's a root pom.xml for the whole repository and a child pom.xml per module.
174 | - The root pom.xml in the root folder provide information which is leverage in every child module.
175 |
176 |
177 |
178 |
179 |
180 | :question:
181 | How many pom.xml is in the [**TrainingLabs**](https://github.com/CertifaiAI/TrainingLabs.git) repository?
182 |
183 | ### Chapter 3 Useful day-to-day operations with Apache Maven & Intellij :man_technologist: :woman_technologist:
184 |
185 | **Note 1: When importing a Maven project into Intellij, open a new project pointing to the root pom.xml. **
186 |
187 | Step 1: Import an existing project
188 |
189 | - There's two approaches in importing an existing project.
190 | First of all, open Intellij in your host system.
191 |
192 | 1. (Option 1) Click "Open or Import" in the "Welcome to IntelliJ IDEA" interface.
193 |
194 |
195 |
196 |
197 | 1. (Option 2) If there's an existing project opened, create a new project by going to **File -> New -> Project from Existing Sources**
198 |
199 |
200 |
201 |
202 | 2. Select the root pom.xml of the repository in which intend to open in Intellij.
203 |
204 |
205 |
206 |
207 | **Note 2 When the IDE is not behave like what you are expecting,
208 | one of the few debugging steps an individual can try to do is clear the cache and restart to see if it solves the problem. **
209 |
210 |
211 |
212 |
213 | **Note 3: The changes in pom.xml will not automatically be reflected when the program is run**.
214 | - Always remember to reload the project once make changes to any of the pom.xml.
215 |
216 | 1. Right click on the repository name. Find **Maven -> Reimport** from the categories.
217 | - In some system, it's **Maven -> Reload project**. Both serves the same purpose.
218 |
219 |
220 |
221 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/dependency_0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/dependency_0.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/dependency_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/dependency_1.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/dependency_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/dependency_2.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/dependency_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/dependency_3.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/import0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/import0.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/import_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/import_1.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/import_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/import_2.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/invalidate.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/invalidate.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/java.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/java.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/javaEnv.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/javaEnv.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/javarelease.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/javarelease.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/javaversion.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/javaversion.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/m2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/m2.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven0.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven1.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven2.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven3.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven4.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven_0.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven_create_project_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven_create_project_0.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven_create_project_0_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven_create_project_0_0.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven_create_project_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven_create_project_1.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven_create_project_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven_create_project_2.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven_create_project_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven_create_project_3.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven_graphic_0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven_graphic_0.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven_graphic_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven_graphic_1.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/maven_graphic_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/maven_graphic_2.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/pom_.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/pom_.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/pom_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/pom_1.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/pom_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/pom_2.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/reload.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/reload.jpg
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/maven/metadata/simplest_pom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/java/ai/certifai/maven/metadata/simplest_pom.png
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/quickstart.md:
--------------------------------------------------------------------------------
1 | # Brief Introduction of Java
2 |
3 | ### Why use Java
4 | ### (Even though it require more lines of codes and debugging)
5 |
6 | - Platform independent.
7 | - Applications developed can work fine on all 0Ses.
8 | - Fast performances compared to other languages
9 | - Java is a compiled language, the types are known during execution.
10 | There's no need of step-by-step executors of source code like interpreted language, which is slower in nature.
11 | - Abundant ecosystems of Tools
12 | - Many industry software and development tools are written and developed in Java.
13 | - Building Android Apps is compatible.
14 | - Most of the android applications are written in Java using Google’s Android API.
15 | - Java has a strong development roadmap with continuous progress in security and performance.
16 |
17 |
18 | ### JVM - JDK - JRE
19 |
20 | There are three keywords to familiarize with in Java Environment.
21 | - Java Runtime Environment (JVM)
22 | - Java Development Kit (JDK)
23 | - Java Runtime Environment (JRE)
24 |
25 |
26 |
27 |
28 |
29 | **Java Runtime Environment (JVM)**
30 | A Java virtual machine (JVM) is a virtual machine which provides a portable execution environment for Java-based applications.
31 |
32 | There are two variations of Java Installation
33 | - Java Runtime Environment (JRE)
34 | - Java Development Kit (JDK)
35 |
36 | **Java Runtime Environment (JRE)**
37 | - Software bundle that allows Java Programs to run
38 | - Does not provide development environment.
39 |
40 | **Java Development Kit (JDK)**
41 | - The full-featured SDK for Java
42 | - **JDK includes JRE**, but also the compiler (javac) and tools (like javadoc and jdb). Hence capable of creating and compiling programs.
43 |
44 | Note:
45 | The JRE is smaller than the JDK with the lack of development tools as it require less disk spaces.
46 |
47 | ### Java Development Timeline
48 |
49 |
50 |
51 |
52 | Java 8 is released on 2014
53 |
54 | ### Installation of Java :man_technologist: :woman_technologist:
55 |
56 | Java can be installed from two sources mainly.
57 | - [Oracle Java](https://www.oracle.com/java/technologies/javase-downloads.html)
58 | - [OpenJDK](https://adoptopenjdk.net/installation.html?variant=openjdk8&jvmVariant=hotspot)
59 |
60 | Check if Java is installed fine on your system :man_technologist: :woman_technologist:
61 | ```$xslt
62 | java -version
63 | ```
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/util/Config.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.util;
18 |
19 | public class Config {
20 |
21 | public static final String OUTPUT_FILE = "output.txt";
22 | public static final String INPUT_FILE = "input.txt";
23 |
24 | public static final String WRONG_MSG = "Wrong answers. Try again.";
25 |
26 | public static final String RIGHT_MSG = "Bingo. Challenge solved.";
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/util/Conversion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.util;
18 |
19 | import java.util.Arrays;
20 | import java.util.Iterator;
21 | import java.util.List;
22 | import java.util.stream.Collectors;
23 |
24 | public class Conversion {
25 |
26 | public static String ListIntegerToString(List list)
27 | {
28 | if((list == null) || list.isEmpty()) return "";
29 |
30 | StringBuilder strbul = new StringBuilder();
31 | Iterator iter = list.iterator();
32 | while(iter.hasNext())
33 | {
34 | strbul.append(iter.next());
35 | if(iter.hasNext()){
36 | strbul.append(" ");
37 | }
38 | }
39 | return strbul.toString();
40 | }
41 |
42 | public static List StringToListInteger(String input)
43 | {
44 | return Arrays.stream(input.split(" ")).map(Integer::parseInt).collect(Collectors.toList());
45 | }
46 |
47 | public static List StringToListString(String input)
48 | {
49 | return Arrays.stream(input.split(" ")).collect(Collectors.toList());
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/util/Dashboard.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.util;
18 |
19 |
20 | import javax.swing.*;
21 | import java.awt.*;
22 |
23 | public class Dashboard {
24 |
25 | private Font font;
26 | private Integer counter = 1;
27 | private String bufferPass = " ";
28 | private String bufferFail = " ";
29 | private Color foregroundColor = Color.WHITE;
30 |
31 | public Dashboard()
32 | {
33 | font = new Font("SansSerif", Font.BOLD, 20);
34 | }
35 |
36 | public void show(java.util.List listResults) {
37 |
38 | JPanel panel = new JPanel(new SpringLayout());
39 | for (Boolean result : listResults)
40 | {
41 | JLabel counterLabel = getCounter();
42 | JTextField textField = getText(result);
43 |
44 | panel.add(counterLabel);
45 | counterLabel.setLabelFor(textField);
46 | panel.add(textField);
47 | }
48 |
49 | SpringUtilities.makeCompactGrid(panel,
50 | listResults.size(), 2, //rows, cols
51 | 6, 6, //initX, initY
52 | 6, 6); //xPad, yPad
53 |
54 | JFrame frame = new JFrame("Result Board");
55 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
56 |
57 | panel.setOpaque(true);
58 | frame.setContentPane(panel);
59 |
60 | frame.setLocationRelativeTo(null);
61 | frame.pack();
62 | frame.setResizable(false);
63 | frame.setVisible(true);
64 | }
65 |
66 | private JLabel getCounter()
67 | {
68 | JLabel counterLabel = new JLabel((counter++) + ". ");
69 | counterLabel.setFont(font);
70 | counterLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
71 | return counterLabel;
72 | }
73 |
74 | private JTextField getText(Boolean isCorrect)
75 | {
76 | String message;
77 | Color backgroundColor;
78 |
79 | if(isCorrect)
80 | {
81 | message = bufferPass + "PASSED" + bufferPass;
82 | backgroundColor = Color.GREEN;
83 | }
84 | else
85 | {
86 | message = bufferFail + "FAILED" + bufferFail;
87 | backgroundColor = Color.RED;
88 | }
89 |
90 | JTextField field = new JTextField(message);
91 |
92 | field.setFont(font);
93 | field.setForeground(foregroundColor);
94 | field.setBackground(backgroundColor);
95 | field.setAlignmentX(Component.CENTER_ALIGNMENT);
96 | field.setEditable(false);
97 |
98 | return field;
99 | }
100 |
101 | }
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/util/FileLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.util;
18 |
19 | import lombok.extern.slf4j.Slf4j;
20 |
21 | import java.io.File;
22 |
23 | /**
24 | * @author codenamewei
25 | */
26 | @Slf4j
27 | public class FileLoader {
28 |
29 | public static File getOutputLoader(Class class_)
30 | {
31 | try
32 | {
33 | ClassLoader loader = class_.getClassLoader();
34 |
35 | String resourcePath = class_.getName().replace(".", "/");
36 | String resourceFile = resourcePath + "/" + Config.OUTPUT_FILE;
37 |
38 | return new File(loader.getResource(resourceFile).getFile());
39 | }
40 | catch(Exception e)
41 | {
42 | log.info("Error when reading input file: " + e.getMessage());
43 | }
44 | return null;
45 | }
46 |
47 | public static File getInputLoader(Class class_)
48 | {
49 | ClassLoader loader = class_.getClassLoader();
50 |
51 | String resourcePath = class_.getName().replace(".", "/");
52 | String resourceFile = resourcePath + "/" + Config.INPUT_FILE;
53 |
54 | return new File(loader.getResource(resourceFile).getFile());
55 | }
56 |
57 | public static File getInputLoader(Class class_, String fileName)
58 | {
59 | ClassLoader loader = class_.getClassLoader();
60 |
61 | String resourcePath = class_.getName().replace(".", "/");
62 | String resourceFile = resourcePath + "/" + fileName;
63 |
64 | return new File(loader.getResource(resourceFile).getFile());
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/util/InputParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.util;
18 |
19 | import lombok.Getter;
20 | import lombok.extern.slf4j.Slf4j;
21 |
22 | import java.io.BufferedReader;
23 | import java.io.File;
24 | import java.io.FileReader;
25 |
26 | /**
27 | * Input parser
28 | *
29 | * @author codenamewei
30 | */
31 | @Slf4j
32 | public class InputParser {
33 |
34 | private boolean classInit = true;
35 |
36 | private String input;
37 | private BufferedReader br;
38 |
39 | @Getter private int currentUseCase = 1;
40 |
41 | @Getter private int totalUseCases;
42 | @Getter private boolean isMultiLine;
43 |
44 | //multipleLine
45 | private int multiLinesBuffer = 0;
46 | private int currentUseCaseTotalLines = 1;
47 |
48 | public InputParser(Class class_)
49 | {
50 | File file = FileLoader.getInputLoader(class_);
51 |
52 | try
53 | {
54 | br = new BufferedReader(new FileReader(file));
55 |
56 | String inputBuffer = br.readLine();
57 |
58 | String[] input = inputBuffer.trim().split("\\s+");
59 |
60 | if(input.length != 2)
61 | {
62 | log.info("Input text file failed with not 2 input. Program expected to failed");
63 | }
64 |
65 | totalUseCases = Integer.parseInt(input[0]);
66 | isMultiLine = Boolean.parseBoolean(input[1]);
67 |
68 | if(isMultiLine)
69 | {
70 | currentUseCaseTotalLines = Integer.parseInt(br.readLine());
71 | }
72 |
73 | }
74 | catch(Exception e)
75 | {
76 | log.info("Error occurs during declare BufferedReader: " + e);
77 | }
78 | }
79 |
80 | private boolean getInputFromFile()
81 | {
82 | try
83 | {
84 | if(!isMultiLine)
85 | {
86 | input = br.readLine();
87 |
88 | if (input == null)
89 | {
90 | throw new Exception("Single line reader end early. Something wrong");
91 | }
92 | else
93 | {
94 | singleLineAddUseCase();
95 | }
96 | }
97 | else
98 | {
99 | if (multiLinesBuffer < currentUseCaseTotalLines)
100 | {
101 | try
102 | {
103 | input = br.readLine();
104 |
105 | if (input == null)
106 | {
107 | throw new Exception("Multi line reader end early. Something wrong");
108 | }
109 | else
110 | {
111 | ++multiLinesBuffer;
112 | }
113 | }
114 | catch (Exception e)
115 | {
116 | log.info(e.getMessage());
117 | }
118 | }
119 | else {
120 | return false;
121 | }
122 | }
123 | }
124 | catch(Exception e)
125 | {
126 | log.info(e.getMessage());
127 | return false;
128 | }
129 |
130 | return true;
131 | }
132 |
133 |
134 | private void flushLine(int numTimes)
135 | {
136 | try {
137 | if (numTimes < 0)
138 | {
139 | log.info("Flush line from negative values. ");
140 | }
141 |
142 | for(int i = 0; i < numTimes; ++i)
143 | {
144 | if(br.readLine() == null)
145 | {
146 | log.info("BufferedReader null while flushing line");
147 | }
148 | }
149 | }
150 | catch(Exception e)
151 | {
152 | log.info(e.getMessage());
153 | }
154 | }
155 |
156 | public String getStringInput()
157 | {
158 | if(getInputFromFile())
159 | {
160 | return input;
161 | }
162 | else
163 | {
164 | return "-1";
165 | }
166 | }
167 |
168 | public int getIntegerInput()
169 | {
170 | try
171 | {
172 | if(getInputFromFile())
173 | {
174 | return Integer.parseInt(input);
175 | }
176 | }
177 | catch(Exception e)
178 | {
179 | log.info("Input cannot parse to integer", e.getMessage());
180 | }
181 |
182 | return -1;
183 | }
184 |
185 | public double getDoubleInput()
186 | {
187 | try
188 | {
189 | if(getInputFromFile())
190 | {
191 | return Double.parseDouble(input);
192 | }
193 | }
194 | catch(Exception e)
195 | {
196 | log.info("Input cannot parse to double", e.getMessage());
197 | }
198 |
199 | return -1D;
200 | }
201 |
202 | public float getFloatInput()
203 | {
204 | try
205 | {
206 | if(getInputFromFile())
207 | {
208 | return Float.parseFloat(input);
209 | }
210 | }
211 | catch(Exception e)
212 | {
213 | log.info("Input cannot parse to float", e.getMessage());
214 | }
215 |
216 | return -1F;
217 | }
218 |
219 | private void singleLineAddUseCase()
220 | {
221 | if(currentUseCase < totalUseCases) ++currentUseCase;
222 | }
223 |
224 | public int getCurrentUseCaseTotalLines()
225 | {
226 | if (currentUseCase >= totalUseCases)
227 | {
228 | log.info("Use Case ended. No more valid input");
229 |
230 | return 0;
231 | }
232 |
233 | if((!isMultiLine) && (currentUseCase < totalUseCases))
234 | {
235 | ++currentUseCase;
236 | }
237 | else if(!classInit)
238 | {
239 | try
240 | {
241 | flushLine(currentUseCaseTotalLines - multiLinesBuffer);
242 | multiLinesBuffer = 0;
243 |
244 | String buffer;
245 | if((buffer = br.readLine()) == null)
246 | {
247 | log.info("Retriving number of total lines for current use case is null");
248 |
249 | return 0;
250 | }
251 | else
252 | {
253 | currentUseCaseTotalLines = Integer.parseInt(buffer);
254 | singleLineAddUseCase();
255 | }
256 |
257 | }
258 | catch(Exception e)
259 | {
260 | log.info(e.getMessage());
261 | }
262 | }
263 | else
264 | {
265 | classInit = false;
266 | }
267 |
268 | return currentUseCaseTotalLines;
269 | }
270 | }
271 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/util/OutputParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.util;
18 |
19 | import lombok.Getter;
20 | import lombok.extern.slf4j.Slf4j;
21 |
22 | import java.io.BufferedReader;
23 | import java.io.File;
24 | import java.io.FileReader;
25 | import java.io.IOException;
26 | import java.util.ArrayList;
27 | import java.util.List;
28 |
29 | /**
30 | * Output parser
31 | *
32 | * @author codenamewei
33 | */
34 | @Slf4j
35 | public class OutputParser
36 | {
37 | private BufferedReader br;
38 | private InputParser in;
39 |
40 | private int currentUseCase = 1;
41 |
42 | @Getter private int totalUseCases;
43 |
44 | //multipleLine
45 | private boolean isMultiLine;
46 |
47 | private int multiLinesBuffer = 1;
48 | private int currentUseCaseTotalLines = 1; //default 1 line if not multi lines
49 | private boolean isCurrentUseCaseFalse = false; //if true, the rest of multi lines of this use case will not change the output
50 |
51 | private List results; //results of size totalUseCases after evaluation
52 |
53 | public OutputParser(Class class_)
54 | {
55 | this(class_, null);
56 | }
57 |
58 | public OutputParser(Class class_, InputParser inputParser)
59 | {
60 | File file = FileLoader.getOutputLoader(class_);
61 | in = inputParser;
62 |
63 | try
64 | {
65 | br = new BufferedReader(new FileReader(file));
66 |
67 | String inputBuffer = br.readLine();
68 |
69 | String[] output = inputBuffer.trim().split("\\s+");
70 |
71 | if(output.length != 2)
72 | {
73 | String paramErrorMessage = "output text file failed with not 2 output. Program expected to failed";
74 |
75 | throw new IOException(paramErrorMessage);
76 | }
77 |
78 | totalUseCases = Integer.parseInt(output[0]);
79 | isMultiLine = Boolean.parseBoolean(output[1]);
80 |
81 | if((in != null) && (totalUseCases != in.getTotalUseCases()))
82 | {
83 | String useCaseNotAligned = "Input use cases != output use cases. Program not able to work fine";
84 |
85 | throw new IOException(useCaseNotAligned);
86 | }
87 |
88 | results = new ArrayList<>();
89 |
90 | if(isMultiLine)
91 | {
92 | currentUseCaseTotalLines = Integer.parseInt(br.readLine());
93 | }
94 |
95 | }
96 | catch(Exception e)
97 | {
98 | log.info("Error occurs during declare BufferedReader: " + e.getMessage());
99 | }
100 | }
101 |
102 | private void flushLine(int numTimes)
103 | {
104 | try {
105 | if (numTimes < 0)
106 | {
107 | log.info("Flush line from negative values. ");
108 | }
109 |
110 | for(int i = 0; i < numTimes; ++i)
111 | {
112 | if(br.readLine() == null)
113 | {
114 | log.info("BufferedReader null while flushing line");
115 | }
116 | }
117 | }
118 | catch(Exception e)
119 | {
120 | log.info(e.getMessage());
121 | }
122 | }
123 |
124 | private void flushUseCase(int numOfUseCase)
125 | {
126 | if(numOfUseCase == 0) return;
127 |
128 | try
129 | {
130 | for(int i = 0; i < numOfUseCase; ++i)
131 | {
132 | if(isMultiLine) flushLine(currentUseCaseTotalLines - multiLinesBuffer + 1);
133 |
134 | String buffer = br.readLine();
135 | if(buffer == null)
136 | {
137 | throw new IOException("Retriving number of total lines for current use case is null");
138 |
139 | }
140 | else
141 | {
142 | if(isMultiLine)
143 | {
144 | currentUseCaseTotalLines = Integer.parseInt(buffer);
145 | multiLinesBuffer = 1;
146 | resultsAddValueIfValid(false);
147 | }
148 | else
149 | {
150 | resultsAddValueIfValid(false);
151 | }
152 | ++currentUseCase;
153 | }
154 |
155 | }
156 | multiLinesBuffer = 1; //?
157 |
158 | if((in != null) && (currentUseCase != in.getCurrentUseCase()))
159 | {
160 | throw new Exception("Output use case index != input use case index");
161 | }
162 |
163 | }
164 | catch(Exception e)
165 | {
166 | log.info(e.getMessage());
167 | }
168 |
169 | }
170 |
171 | private void resultsAddValueIfValid(boolean state)
172 | {
173 | if(results.size() < totalUseCases)
174 | {
175 | results.add(state);
176 | }
177 | else
178 | {
179 | log.info("Results size is more than total use cases. State not saved");
180 | }
181 | }
182 |
183 | private boolean getResult(Object input)
184 | {
185 | boolean bResult = false;
186 |
187 | if(input instanceof String)
188 | {
189 | bResult = compareString((String) input);
190 | }
191 | else if(input instanceof Integer)
192 | {
193 | bResult = compareInteger((Integer) input);
194 | }
195 | else if(input instanceof Float)
196 | {
197 | bResult = compareFloat((Float) input);
198 | }
199 | else if(input instanceof Boolean)
200 | {
201 | bResult = compareBoolean((Boolean) input);
202 | }
203 |
204 |
205 | return bResult;
206 | }
207 |
208 | public void evaluate(Object input)
209 | {
210 | try
211 | {
212 | if(isMultiLine)
213 | {
214 | if(in == null)
215 | {
216 | throw new Exception("Input parse is null. Program cant function well");
217 | }
218 |
219 | if(in.getCurrentUseCase() > totalUseCases)
220 | {
221 | return; // use case ended do nothing
222 | }
223 |
224 | if(in.isMultiLine())
225 | {
226 | if(in.getCurrentUseCase() > currentUseCase)
227 | {
228 | flushUseCase(in.getCurrentUseCase() - currentUseCase);
229 | }
230 | else if(in.getCurrentUseCase() < currentUseCase)
231 | {
232 | results.remove(results.size() - 1);
233 | results.add(false);
234 | }
235 | }
236 |
237 | if(multiLinesBuffer > currentUseCaseTotalLines)
238 | {
239 | results.remove(results.size() - 1);
240 | results.add(false);
241 | }
242 | else
243 | {
244 | if((!isCurrentUseCaseFalse) && (!getResult(input)))
245 | {
246 | isCurrentUseCaseFalse = true;
247 | }
248 |
249 | ++multiLinesBuffer;
250 |
251 | if(multiLinesBuffer == (currentUseCaseTotalLines + 1) )
252 | {
253 | resultsAddValueIfValid(!isCurrentUseCaseFalse);
254 |
255 | ++currentUseCase;
256 |
257 | if(currentUseCase <= totalUseCases)
258 | {
259 | String nextTotalLines = br.readLine();
260 |
261 | if (nextTotalLines == null)
262 | {
263 | log.info("Output line reader end early. Something wrong");
264 | }
265 | else
266 | {
267 | currentUseCaseTotalLines = Integer.parseInt(nextTotalLines);
268 | multiLinesBuffer = 1;
269 | }
270 | }
271 | }
272 | }
273 | }
274 | else
275 | {
276 | flushSingleLineUseCase();
277 | resultsAddValueIfValid(getResult(input));
278 |
279 | ++currentUseCase;
280 |
281 | }
282 | }
283 | catch(Exception e)
284 | {
285 | log.info("Error: " + e.getMessage());
286 | }
287 |
288 | }
289 |
290 | private void flushSingleLineUseCase()
291 | {
292 | if(in == null) return;
293 |
294 | if( (currentUseCase != totalUseCases) && (in.getCurrentUseCase() > (currentUseCase + 1)))
295 | {
296 | int numOfUseCaseToFlush = in.getCurrentUseCase() - currentUseCase - 1;
297 |
298 | flushUseCase(numOfUseCaseToFlush);
299 | }
300 | }
301 |
302 |
303 | private boolean compareString(String input)
304 | {
305 | String trueOutput = getTrueOutput();
306 |
307 | return trueOutput.equals(input);
308 | }
309 |
310 |
311 | private boolean compareInteger(Integer input)
312 | {
313 | String trueOutput = getTrueOutput();
314 |
315 | return input.equals(Integer.parseInt(trueOutput));
316 | }
317 |
318 | private boolean compareFloat(Float input)
319 | {
320 | String trueOutput = getTrueOutput();
321 |
322 | return input.equals(Float.parseFloat(trueOutput));
323 | }
324 |
325 | private boolean compareBoolean(Boolean input)
326 | {
327 | String trueOutput = getTrueOutput();
328 |
329 | return input == Boolean.parseBoolean(trueOutput);
330 | }
331 |
332 | private String getTrueOutput() {
333 |
334 | String outputBuffer = "";
335 |
336 | try
337 | {
338 | outputBuffer = br.readLine();
339 |
340 | if (outputBuffer == null)
341 | {
342 | log.info("Output line reader end early. Something wrong");
343 | }
344 | }
345 | catch(Exception e)
346 | {
347 | log.info(e.getMessage());
348 | }
349 |
350 | return outputBuffer;
351 |
352 | }
353 |
354 |
355 | public void printResult()
356 | {
357 | if (currentUseCase <= totalUseCases)
358 | {
359 | int numOfUseCasesSkip = totalUseCases - currentUseCase + 1;
360 |
361 | for (int i = 0; i < numOfUseCasesSkip; ++i) {
362 | resultsAddValueIfValid(false);
363 | }
364 | }
365 | else if(isMultiLine && (currentUseCase == totalUseCases) && (multiLinesBuffer <= currentUseCaseTotalLines))
366 | {
367 | resultsAddValueIfValid(false);
368 | }
369 |
370 | new Dashboard().show(results);
371 | }
372 | }
373 |
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/util/PathHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.util;
18 |
19 | import java.io.File;
20 |
21 | public class PathHandler {
22 |
23 | public static String getPathToFile(String pathName) {
24 | String[] subString = pathName.split("/");
25 | String fullPathName = subString[subString.length - 1];
26 |
27 | String[] separator = fullPathName.split("\\.");
28 |
29 | int fileEndIndex = fullPathName.length() - separator[(separator.length - 1)].length() - 1;
30 | String fileName = fullPathName.substring(0, fileEndIndex);
31 |
32 | Integer pathLength = pathName.length() - fullPathName.length();
33 | String pathToSave = pathName.substring(0, pathLength);
34 |
35 | fileName = fileName.replace(".", "_"); //replace any possible "." with "_"
36 | fileName = fileName.replace(" ", ""); //replace any possible " " with ""
37 |
38 | String pathFirstHalf = pathToSave + fileName;
39 |
40 | return pathFirstHalf;
41 | }
42 |
43 | public static Boolean isFileValid(String pathName) {
44 |
45 | try {
46 | File fileImagePath = new File(pathName);
47 |
48 | if (fileImagePath.exists() == false) {
49 | System.out.println("File did not exist");
50 | return false;
51 | }
52 | } catch (Exception e) {
53 | System.out.println("Error happened when reading in image.");
54 | e.printStackTrace();
55 | return false;
56 | }
57 |
58 | return true;
59 | }
60 | }
--------------------------------------------------------------------------------
/java-core/src/main/java/ai/certifai/util/SpringUtilities.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020-2021 CertifAI Sdn. Bhd.
3 | *
4 | * This program is part of OSRFramework. You can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version. You should have received a copy of the
8 | * GNU Affero General Public License along with this program. If not, see
9 | *
10 | * https://www.gnu.org/licenses/agpl-3.0
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Affero General Public License for more details.
16 | */
17 | package ai.certifai.util;
18 |
19 | import javax.swing.*;
20 | import java.awt.*;
21 |
22 | /**
23 | * A 1.4 file that provides utility methods for
24 | * creating form- or grid-style layouts with SpringLayout.
25 | * These utilities are used by several programs, such as
26 | * SpringBox and SpringCompactGrid.
27 | */
28 | public class SpringUtilities {
29 | /**
30 | * A debugging utility that prints to stdout the component's
31 | * minimum, preferred, and maximum sizes.
32 | */
33 | public static void printSizes(Component c) {
34 | System.out.println("minimumSize = " + c.getMinimumSize());
35 | System.out.println("preferredSize = " + c.getPreferredSize());
36 | System.out.println("maximumSize = " + c.getMaximumSize());
37 | }
38 |
39 | /**
40 | * Aligns the first rows * cols
41 | * components of parent in
42 | * a grid. Each component is as big as the maximum
43 | * preferred width and height of the components.
44 | * The parent is made just big enough to fit them all.
45 | *
46 | * @param rows number of rows
47 | * @param cols number of columns
48 | * @param initialX x location to start the grid at
49 | * @param initialY y location to start the grid at
50 | * @param xPad x padding between cells
51 | * @param yPad y padding between cells
52 | */
53 | public static void makeGrid(Container parent,
54 | int rows, int cols,
55 | int initialX, int initialY,
56 | int xPad, int yPad) {
57 | SpringLayout layout;
58 | try {
59 | layout = (SpringLayout)parent.getLayout();
60 | } catch (ClassCastException exc) {
61 | System.err.println("The first argument to makeGrid must use SpringLayout.");
62 | return;
63 | }
64 |
65 | Spring xPadSpring = Spring.constant(xPad);
66 | Spring yPadSpring = Spring.constant(yPad);
67 | Spring initialXSpring = Spring.constant(initialX);
68 | Spring initialYSpring = Spring.constant(initialY);
69 | int max = rows * cols;
70 |
71 | //Calculate Springs that are the max of the width/height so that all
72 | //cells have the same size.
73 | Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).
74 | getWidth();
75 | Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).
76 | getHeight();
77 | for (int i = 1; i < max; i++) {
78 | SpringLayout.Constraints cons = layout.getConstraints(
79 | parent.getComponent(i));
80 |
81 | maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
82 | maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
83 | }
84 |
85 | //Apply the new width/height Spring. This forces all the
86 | //components to have the same size.
87 | for (int i = 0; i < max; i++) {
88 | SpringLayout.Constraints cons = layout.getConstraints(
89 | parent.getComponent(i));
90 |
91 | cons.setWidth(maxWidthSpring);
92 | cons.setHeight(maxHeightSpring);
93 | }
94 |
95 | //Then adjust the x/y constraints of all the cells so that they
96 | //are aligned in a grid.
97 | SpringLayout.Constraints lastCons = null;
98 | SpringLayout.Constraints lastRowCons = null;
99 | for (int i = 0; i < max; i++) {
100 | SpringLayout.Constraints cons = layout.getConstraints(
101 | parent.getComponent(i));
102 | if (i % cols == 0) { //start of new row
103 | lastRowCons = lastCons;
104 | cons.setX(initialXSpring);
105 | } else { //x position depends on previous component
106 | cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST),
107 | xPadSpring));
108 | }
109 |
110 | if (i / cols == 0) { //first row
111 | cons.setY(initialYSpring);
112 | } else { //y position depends on previous row
113 | cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH),
114 | yPadSpring));
115 | }
116 | lastCons = cons;
117 | }
118 |
119 | //Set the parent's size.
120 | SpringLayout.Constraints pCons = layout.getConstraints(parent);
121 | pCons.setConstraint(SpringLayout.SOUTH,
122 | Spring.sum(
123 | Spring.constant(yPad),
124 | lastCons.getConstraint(SpringLayout.SOUTH)));
125 | pCons.setConstraint(SpringLayout.EAST,
126 | Spring.sum(
127 | Spring.constant(xPad),
128 | lastCons.getConstraint(SpringLayout.EAST)));
129 | }
130 |
131 | /* Used by makeCompactGrid. */
132 | private static SpringLayout.Constraints getConstraintsForCell(
133 | int row, int col,
134 | Container parent,
135 | int cols) {
136 | SpringLayout layout = (SpringLayout) parent.getLayout();
137 | Component c = parent.getComponent(row * cols + col);
138 | return layout.getConstraints(c);
139 | }
140 |
141 | /**
142 | * Aligns the first rows * cols
143 | * components of parent in
144 | * a grid. Each component in a column is as wide as the maximum
145 | * preferred width of the components in that column;
146 | * height is similarly determined for each row.
147 | * The parent is made just big enough to fit them all.
148 | *
149 | * @param rows number of rows
150 | * @param cols number of columns
151 | * @param initialX x location to start the grid at
152 | * @param initialY y location to start the grid at
153 | * @param xPad x padding between cells
154 | * @param yPad y padding between cells
155 | */
156 | public static void makeCompactGrid(Container parent,
157 | int rows, int cols,
158 | int initialX, int initialY,
159 | int xPad, int yPad) {
160 | SpringLayout layout;
161 | try {
162 | layout = (SpringLayout)parent.getLayout();
163 | } catch (ClassCastException exc) {
164 | System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
165 | return;
166 | }
167 |
168 | //Align all cells in each column and make them the same width.
169 | Spring x = Spring.constant(initialX);
170 | for (int c = 0; c < cols; c++) {
171 | Spring width = Spring.constant(0);
172 | for (int r = 0; r < rows; r++) {
173 | width = Spring.max(width,
174 | getConstraintsForCell(r, c, parent, cols).
175 | getWidth());
176 | }
177 | for (int r = 0; r < rows; r++) {
178 | SpringLayout.Constraints constraints =
179 | getConstraintsForCell(r, c, parent, cols);
180 | constraints.setX(x);
181 | constraints.setWidth(width);
182 | }
183 | x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
184 | }
185 |
186 | //Align all cells in each row and make them the same height.
187 | Spring y = Spring.constant(initialY);
188 | for (int r = 0; r < rows; r++) {
189 | Spring height = Spring.constant(0);
190 | for (int c = 0; c < cols; c++) {
191 | height = Spring.max(height,
192 | getConstraintsForCell(r, c, parent, cols).
193 | getHeight());
194 | }
195 | for (int c = 0; c < cols; c++) {
196 | SpringLayout.Constraints constraints =
197 | getConstraintsForCell(r, c, parent, cols);
198 | constraints.setY(y);
199 | constraints.setHeight(height);
200 | }
201 | y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));
202 | }
203 |
204 | //Set the parent's size.
205 | SpringLayout.Constraints pCons = layout.getConstraints(parent);
206 | pCons.setConstraint(SpringLayout.SOUTH, y);
207 | pCons.setConstraint(SpringLayout.EAST, x);
208 | }
209 | }
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/basic/ex1/HelloWorld/output.txt:
--------------------------------------------------------------------------------
1 | 1 false
2 | Hello World!
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/basic/ex2/PackagingIntro/output.txt:
--------------------------------------------------------------------------------
1 | 1 false
2 | Package Name = ai.certifai.basic.ex2.PackagingIntro
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/basic/ex3/BluePrint/input.txt:
--------------------------------------------------------------------------------
1 | 1 true
2 | 3
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/basic/ex3/BluePrint/output.txt:
--------------------------------------------------------------------------------
1 | 1 true
2 | 3
3 | Name: John Doe
4 | Height: 165
5 | Width: 100
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/basic/ex5/If_ElseIf_Else/input.txt:
--------------------------------------------------------------------------------
1 | 11 false
2 | 2
3 | 50
4 | 0
5 | 1000
6 | 10001
7 | 121
8 | 6
9 | 1000000
10 | 5
11 | 87
12 | 101
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/basic/ex5/If_ElseIf_Else/output.txt:
--------------------------------------------------------------------------------
1 | 11 false
2 | Even
3 | Special
4 | Even
5 | Even
6 | Out of Range
7 | Odd
8 | Even
9 | Out of Range
10 | Odd
11 | Special
12 | Odd
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/basic/ex6/DataTypes/input.txt:
--------------------------------------------------------------------------------
1 | 1 true
2 | 4
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/basic/ex6/DataTypes/output.txt:
--------------------------------------------------------------------------------
1 | 1 true
2 | 4
3 | Nasi Lemak!
4 | 20
5 | 100.054
6 | true
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/basic/ex7/ForLoop/input.txt:
--------------------------------------------------------------------------------
1 | 4 true
2 | 4
3 | Manchester United
4 | Real Madrid
5 | Liverpool
6 | Barcelona
7 | 7
8 | ********* ********* ********* ********* ********* ********* ***** *********
9 | ********* ********* ** ** ********* ********* ********* ********* *********
10 | *** *** ** ** *** *** *** *** *** ***
11 | *** ********* ********* *** *** ********* *** *** ***
12 | *** *** ******* *** *** ********* ********* ***
13 | ********* ********* *** *** *** ********* *** *** *** *********
14 | ********* ********* *** *** *** ********* *** *** *** *********
15 | 3
16 | Just
17 | Do
18 | It!
19 | 1
20 | no
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/basic/ex7/ForLoop/output.txt:
--------------------------------------------------------------------------------
1 | 4 true
2 | 4
3 | Manchester United
4 | Real Madrid
5 | Liverpool
6 | Barcelona
7 | 7
8 | ********* ********* ********* ********* ********* ********* ***** *********
9 | ********* ********* ** ** ********* ********* ********* ********* *********
10 | *** *** ** ** *** *** *** *** *** ***
11 | *** ********* ********* *** *** ********* *** *** ***
12 | *** *** ******* *** *** ********* ********* ***
13 | ********* ********* *** *** *** ********* *** *** *** *********
14 | ********* ********* *** *** *** ********* *** *** *** *********
15 | 3
16 | Just
17 | Do
18 | It!
19 | 1
20 | no
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex10/ExceptionHandling/output.txt:
--------------------------------------------------------------------------------
1 | 3 false
2 | java.io.FileNotFoundException
3 | java.lang.ArithmeticException
4 | java.lang.NullPointerException
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex11/WhileLoop/1.txt:
--------------------------------------------------------------------------------
1 | true
2 | true
3 | true
4 | false
5 | false
6 | false
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex11/WhileLoop/2.txt:
--------------------------------------------------------------------------------
1 | Sep 09, 2020 05:47:51 PM
2 | Sep 09, 2020 05:47:52 PM
3 | Sep 09, 2020 05:47:53 PM
4 | Sep 09, 2020 05:47:53 PM
5 | Sep 09, 2020 05:47:56 PM
6 | Sep 09, 2020 05:47:56 PM
7 | Sep 09, 2020 05:48:07 PM
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex11/WhileLoop/3.txt:
--------------------------------------------------------------------------------
1 | Designed and Developed various mechanical and structural parts for global TV market from concept to launch.
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex11/WhileLoop/4.txt:
--------------------------------------------------------------------------------
1 | Try the cloud-native development solutions from Red Hat,
2 | and experience how you can build apps more efficiently and deliver faster!
3 | Get the e-book here.
4 | Make growth happen with AI that works for you!
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex11/WhileLoop/5.txt:
--------------------------------------------------------------------------------
1 | Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: PROJECTNAME
2 | at org.hsqldb.error.Error.error(Unknown Source)
3 | at org.hsqldb.error.Error.error(Unknown Source)
4 | at org.hsqldb.ExpressionColumn.checkColumnsResolved(Unknown Source)
5 | at org.hsqldb.QueryExpression.resolve(Unknown Source)
6 | at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
7 | at org.hsqldb.ParserCommand.compilePart(Unknown Source)
8 | at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
9 | at org.hsqldb.Session.compileStatement(Unknown Source)
10 | at org.hsqldb.StatementManager.compile(Unknown Source)
11 | at org.hsqldb.Session.execute(Unknown Source)
12 | ... 13 common frames omitted
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex11/WhileLoop/6.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/java-core/src/main/resources/ai/certifai/intermediate/ex11/WhileLoop/6.txt
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex11/WhileLoop/7.txt:
--------------------------------------------------------------------------------
1 | Meaning of text in English:
2 |
3 |
4 | text
5 | Pronunciation /tɛkst/
6 | Translate text into Spanish
7 |
8 | NOUN
9 | 1A book or other written or printed work, regarded in terms of its content rather than its physical form.
10 |
11 | ‘a text which explores pain and grief’
12 | More example sentencesSynonyms
13 | 1.1A piece of written or printed material regarded as conveying the authentic or primary form of a particular work.
14 | ‘in some passages it is difficult to establish the original text’
15 | More example sentences
16 | 1.2mass noun Written or printed words, typically forming a connected piece of work.
17 | ‘stylistic features of journalistic text’
18 | More example sentences
19 | 1.3Computing mass noun Data in the form of words or alphabetic characters.
20 | ‘For my purposes, clearly displaying a lot of text at relatively small font sizes is the most important thing I want a monitor to do.’
21 | More example sentences
22 | 2in singular The main body of a book or other piece of writing, as distinct from other material such as notes, appendices, and illustrations.
23 |
24 | ‘the pictures are clear and relate well to the text’
25 | More example sentencesSynonyms
26 | 2.1A script or libretto.
27 | ‘There are laughs to be had from the updated text, and Shakespeare's basic story is as entertaining as ever.’
28 | More example sentencesSynonyms
29 | 3A written work chosen or set as a subject of study.
30 |
31 | ‘too much concentration on set texts can turn pupils against reading’
32 | More example sentences
33 | 3.1A textbook.
34 | ‘an organic chemistry text’
35 | More example sentencesSynonyms
36 | 3.2A passage from the Bible or other religious work, especially when used as the subject of a sermon.
37 | ‘The first is that all the readings of texts and the sermons have been provided by biblical specialists, attempting to read theologically.’
38 | More example sentencesSynonyms
39 | 3.3A subject or theme for a discussion or exposition.
40 | ‘he took as his text the fact that Australia is paradise’
41 | More example sentencesSynonyms
42 | 4A text message.
43 |
44 | ‘just give us a call or send us a text’
45 | More example sentences
46 | 5
47 |
48 | (also text-hand)
49 | mass noun Fine, large handwriting, used especially for manuscripts.
50 | VERB
51 | [WITH OBJECT]
52 | Send (someone) a text message.
53 |
54 | ‘if she was going to go she would have texted us’
55 | More example sentences
56 | Origin
57 | Late Middle English from Old Northern French texte, from Latin textus ‘tissue, literary style’ (in medieval Latin, ‘Gospel’), from text- ‘woven’, from the verb texere.
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex11/WhileLoop/input.txt:
--------------------------------------------------------------------------------
1 | 7 false
2 | 1.txt
3 | 2.txt
4 | 3.txt
5 | 4.txt
6 | 5.txt
7 | 6.txt
8 | 7.txt
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex11/WhileLoop/output.txt:
--------------------------------------------------------------------------------
1 | 7 false
2 | 6
3 | 7
4 | 1
5 | 4
6 | 12
7 | 0
8 | 57
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex12/MapImp/input.txt:
--------------------------------------------------------------------------------
1 | 10 false
2 | get Italy
3 | delete Tuvalu
4 | add Tuvalu 688
5 | add Singapore 65
6 | get Singapore
7 | delete Singapore
8 | get Malaysia
9 | get Romania
10 | delete Uganda
11 | get Uganda
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex12/MapImp/output.txt:
--------------------------------------------------------------------------------
1 | 10 false
2 | 39
3 | False
4 | True
5 | False
6 | 65
7 | True
8 | 60
9 | False
10 | False
11 | False
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex13/SubString/input.txt:
--------------------------------------------------------------------------------
1 | 11 false
2 | debug.log
3 | Image from iOS (2).jpg
4 | Capture.PNG
5 | Screenshot 2020-09-17 204314.jpg
6 | Classifai_WelcomeHandler_A
7 | chrome-linux.zip
8 | Classifai_Favicon_Light_BG.ico
9 | Certifai Milo Poster.png
10 | a
11 | The Data Engineering Cookbook.pdf
12 | NLP
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex13/SubString/output.txt:
--------------------------------------------------------------------------------
1 | 11 false
2 | log
3 | jpg
4 | PNG
5 | jpg
6 | It's not a file!
7 | zip
8 | ico
9 | png
10 | It's not a file!
11 | pdf
12 | It's not a file!
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex14/AdvancedSubString/input.txt:
--------------------------------------------------------------------------------
1 | 12 false
2 | java-fundamentals
3 | Image from iOS (2).jpg
4 | Capture.PNG
5 | Screenshot 2020-09-17 204314.jpg
6 | Classifai_WelcomeHandler_A
7 | Custom Office Templates
8 | c
9 | Certifai Milo Poster.png
10 | 1
11 | The Data Engineering Cookbook.pdf
12 | Quick Access
13 | a b c
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex14/AdvancedSubString/output.txt:
--------------------------------------------------------------------------------
1 | 12 false
2 | java-fundamentals
3 | Image_from_iOS_(2)
4 | Capture
5 | Screenshot_2020-09-17_204314
6 | Classifai_WelcomeHandler_A
7 | Custom_Office_Templates
8 | c
9 | Certifai_Milo_Poster
10 | 1
11 | The_Data_Engineering_Cookbook
12 | Quick_Access
13 | a_b_c
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex15/QuickSortImp/input.txt:
--------------------------------------------------------------------------------
1 | 7 false
2 | 10 7 8 23 1 52
3 | 1001 1050 1031
4 | 1 4 5 1 56 90 9
5 | 9 4 5 6 11244 466 1245 10
6 | 234 123
7 | 0
8 | 12 7 80
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex15/QuickSortImp/output.txt:
--------------------------------------------------------------------------------
1 | 7 false
2 | 1 7 8 10 23 52
3 | 1001 1031 1050
4 | 1 1 4 5 9 56 90
5 | 4 5 6 9 10 466 1245 11244
6 | 123 234
7 | 0
8 | 7 12 80
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex8/OrderedCollection/input.txt:
--------------------------------------------------------------------------------
1 | 5 false
2 | 2 2 3
3 | 4 6 1
4 | 1 0
5 | 10
6 | 15 2 500 4 1000 5 6 7
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex8/OrderedCollection/output.txt:
--------------------------------------------------------------------------------
1 | 5 true
2 | 3
3 | 2
4 | 2
5 | 3
6 | 3
7 | 4
8 | 6
9 | 1
10 | 2
11 | 1
12 | 0
13 | 1
14 | 10
15 | 8
16 | 15
17 | 2
18 | 500
19 | 4
20 | 1000
21 | 5
22 | 6
23 | 7
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex9/AdvancedForLoop/input.txt:
--------------------------------------------------------------------------------
1 | 5 false
2 | 2 2 3
3 | 4 6 1
4 | 1 0 5
5 | 10 1 1
6 | 15 2 500
--------------------------------------------------------------------------------
/java-core/src/main/resources/ai/certifai/intermediate/ex9/AdvancedForLoop/output.txt:
--------------------------------------------------------------------------------
1 | 5 false
2 | 7 18
3 | 65 194 451 964
4 | 6
5 | 3 8 17 34 67 132 261 518 1031 2056
6 | 504 1012 1528 2060 2624 3252 4008 5020 6544 9092 13688 22380 39264 72532 138568
--------------------------------------------------------------------------------
/java-core/src/main/resources/solutionStructureGuidance.md:
--------------------------------------------------------------------------------
1 | # input file (multiline == true)
2 | number of use case, multiline
3 | num of lines for use case 0
4 | ..
5 | num of lines for use case 1
6 | ..
7 |
8 | # input file (multiline == false)
9 | number of use case, multiline
10 | question use case 0
11 | question use case 1
12 | ..
13 |
14 | # output file
15 | number of use case, multiline(true)
16 | number of lines of use case 0
17 | ans 0 use case 0
18 | ans 0 use case 1
19 | ..
20 | number of lines of use case 1
21 | ans 1 use case 0
22 | ans 1 use case 1
23 | ..
24 |
25 | # output file (if input multiline == false)
26 | number of use case, multiline(false)
27 | ans use case 0
28 | ans use case 1
29 | ..
--------------------------------------------------------------------------------
/metadata/codeSample.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/metadata/codeSample.JPG
--------------------------------------------------------------------------------
/metadata/dashboard.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/metadata/dashboard.jpg
--------------------------------------------------------------------------------
/metadata/fileStructure.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/metadata/fileStructure.jpg
--------------------------------------------------------------------------------
/metadata/head.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/metadata/head.gif
--------------------------------------------------------------------------------
/metadata/try.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CertifaiAI/learn-java-the-certifai-way/1b62cf91c3f0d9384d63f4599ce13ea838290f9a/metadata/try.jpg
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
21 | 4.0.0
22 |
23 | ai.certifai
24 | learn-java-the-certifai-way
25 | pom
26 | 1.0-SNAPSHOT
27 |
28 |
29 |
30 |
31 | CertifaiAI_learn-java-the-certifai-way
32 | ${project.artifactId}
33 | certifaiai
34 | https://sonarcloud.io
35 |
36 |
37 |
38 |
39 | java-core
40 |
41 |
42 | learn-java-the-certifai-way
43 |
44 | Fundamentals of Java Programming
45 |
46 | http://certifai.ai
47 |
48 |
49 |
50 | Apache License, Version 2.0
51 | https://www.apache.org/licenses/LICENSE-2.0.txt
52 | repo
53 |
54 |
55 |
56 |
57 |
58 | codenamewei
59 | Chiawei Lim
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------