├── .gitignore
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── hangman
├── C#
│ ├── .gitignore
│ ├── Hangman
│ │ ├── .gitignore
│ │ ├── App.config
│ │ ├── Hangman.csproj
│ │ ├── Hangman.sln
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── resources
│ │ │ └── words.in
│ └── README.md
├── C++
│ ├── .gitignore
│ ├── README.md
│ └── hangman
│ │ ├── main.cpp
│ │ └── resources
│ │ └── words.in
├── C
│ ├── .gitignore
│ ├── README.md
│ └── hangman
│ │ └── resources
│ │ ├── main.c
│ │ └── words.in
├── Go
│ ├── README.md
│ ├── hangman.go
│ └── resources
│ │ └── words.in
├── Groovy
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── groovy
│ │ └── com
│ │ │ └── floppylab
│ │ │ └── refactor
│ │ │ └── Hangman.groovy
│ │ └── resources
│ │ └── words.in
├── Java
│ ├── README.md
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── floppylab
│ │ │ └── refactor
│ │ │ └── Hangman.java
│ │ └── resources
│ │ └── words.in
├── JavaScript
│ ├── .gitignore
│ ├── .nvmrc
│ ├── hangman.js
│ ├── package-lock.json
│ ├── package.json
│ ├── readme.md
│ └── resources
│ │ └── words.in
├── Kotlin
│ ├── README.md
│ ├── hangman.kt
│ └── resources
│ │ └── words.in
├── Python
│ └── Hangman
│ │ ├── .gitignore
│ │ ├── Hangman.py
│ │ ├── README.md
│ │ └── resources
│ │ └── words.in
├── README.md
└── Rust
│ ├── .gitignore
│ ├── Cargo.toml
│ ├── resources
│ └── words.in
│ └── src
│ └── main.rs
└── matchsticks
├── C++
├── README.md
└── matchsticks.cpp
├── C
├── .gitignore
├── README.md
└── matchsticks.c
├── Java
├── README.md
└── matchsticks
│ ├── .gitignore
│ ├── pom.xml
│ └── src
│ ├── main
│ └── java
│ │ └── floppylab
│ │ └── matchsticks
│ │ └── Matchsticks.java
│ └── test
│ └── java
│ └── floppylab
│ └── matchsticks
│ └── MatchsticksTest.java
├── JavaScript
├── README.md
└── matchsticks.js
├── Kotlin
├── README.md
└── matchsticks.kt
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6 |
7 | ## Our Standards
8 |
9 | Examples of behavior that contributes to creating a positive environment include:
10 |
11 | * Using welcoming and inclusive language
12 | * Being respectful of differing viewpoints and experiences
13 | * Gracefully accepting constructive criticism
14 | * Focusing on what is best for the community
15 | * Showing empathy towards other community members
16 |
17 | Examples of unacceptable behavior by participants include:
18 |
19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances
20 | * Trolling, insulting/derogatory comments, and personal or political attacks
21 | * Public or private harassment
22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission
23 | * Other conduct which could reasonably be considered inappropriate in a professional setting
24 |
25 | ## Our Responsibilities
26 |
27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28 |
29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30 |
31 | ## Scope
32 |
33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34 |
35 | ## Enforcement
36 |
37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at info@floppylab.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38 |
39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40 |
41 | ## Attribution
42 |
43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44 |
45 | [homepage]: http://contributor-covenant.org
46 | [version]: http://contributor-covenant.org/version/1/4/
47 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2018 floppylab
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # A collection of pieces of code to practice refactoring
2 |
3 | You can find pieces of simple programs here you can work on. These will help you to improve your refactoring skills.
4 |
5 | ## Collection
6 |
7 | - [Hangman](hangman)
8 | - [Matchsticks](matchsticks)
9 |
--------------------------------------------------------------------------------
/hangman/C#/.gitignore:
--------------------------------------------------------------------------------
1 | # MS Visual Studio
2 | *.suo
3 | *.csproj.user
--------------------------------------------------------------------------------
/hangman/C#/Hangman/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
--------------------------------------------------------------------------------
/hangman/C#/Hangman/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/hangman/C#/Hangman/Hangman.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {1769ED1B-D62A-45A7-AB21-3CBB2DDE2180}
8 | Exe
9 | Properties
10 | Hangman
11 | Hangman
12 | v4.5.2
13 | 512
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
61 |
--------------------------------------------------------------------------------
/hangman/C#/Hangman/Hangman.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28010.2046
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hangman", "Hangman.csproj", "{1769ED1B-D62A-45A7-AB21-3CBB2DDE2180}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {1769ED1B-D62A-45A7-AB21-3CBB2DDE2180}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {1769ED1B-D62A-45A7-AB21-3CBB2DDE2180}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {1769ED1B-D62A-45A7-AB21-3CBB2DDE2180}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {1769ED1B-D62A-45A7-AB21-3CBB2DDE2180}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {9142AE20-9C6F-491E-90DE-EF444BB5F0B1}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/hangman/C#/Hangman/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 |
6 | namespace Hangman
7 | {
8 | class Program
9 | {
10 | static void Main(string[] args)
11 | {
12 | Dictionary> d = new Dictionary>();
13 | List w = new List();
14 |
15 | var wordsPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent?.FullName + @"\resources\words.in";
16 | string line;
17 |
18 | // reading text file line by line
19 | using (StreamReader reader = new StreamReader(wordsPath))
20 | {
21 | while ((line = reader.ReadLine()) != null)
22 | {
23 | w.Add(line);
24 | }
25 | }
26 |
27 | // sorting words by length
28 | for (int i = 0; i < w.Count; i++)
29 | {
30 | if (!d.ContainsKey(w[i].Length))
31 | {
32 | d.Add(w[i].Length, new List());
33 | }
34 | d[w[i].Length].Add(w[i]);
35 | }
36 |
37 |
38 |
39 | int userInputNumOfLetters;
40 | while (true)
41 | {
42 | Console.WriteLine("Number of letters in the word? ");
43 | userInputNumOfLetters = Convert.ToInt32(Console.ReadLine());
44 | if (userInputNumOfLetters < 6)
45 | {
46 | Console.Clear();
47 | Console.WriteLine("Please enter a word length 6 or more");
48 | }
49 | else if (userInputNumOfLetters > 14)
50 | {
51 | Console.Clear();
52 | Console.WriteLine("Please enter a word length 14 or less");
53 | }
54 | else
55 | {
56 | break;
57 | }
58 | }
59 |
60 | if (d.ContainsKey(userInputNumOfLetters))
61 | {
62 | // choose a random word with the given length
63 | string word = d[userInputNumOfLetters][new Random().Next(d[userInputNumOfLetters].Count)];
64 | bool[] v = new bool[word.Length];
65 | int e = 0;
66 | bool done = true;
67 |
68 | while (e < 10)
69 | {
70 |
71 | done = true;
72 | for (int i = 0; i < word.Length; ++i)
73 | {
74 | if (!v[i])
75 | {
76 | done = false;
77 | }
78 | }
79 | if (done)
80 | {
81 | break;
82 | }
83 |
84 | Console.WriteLine("Guess a letter: ");
85 | char chr = Convert.ToChar(Console.ReadLine()[0]);
86 |
87 | // TODO check if previously entered
88 | bool hit = false;
89 | for (int i = 0; i < word.Length; ++i)
90 | {
91 | if (word[i] == chr && !v[i])
92 | {
93 | v[i] = true;
94 | hit = true;
95 | }
96 | }
97 | if (hit)
98 | {
99 | Console.WriteLine("Hit!");
100 | }
101 | else {
102 | Console.WriteLine("Missed, mistake {0} out of {1}", e+1, 10);
103 | ++e;
104 |
105 | // drawing hangman
106 | Console.WriteLine();
107 | if (e > 2) Console.WriteLine(" xxxxxxxxxxxxx");
108 | else Console.WriteLine();
109 |
110 | if (e > 3) Console.WriteLine(" x x");
111 | else if (e > 1) Console.WriteLine(" x");
112 | else Console.WriteLine();
113 |
114 | if (e > 3) Console.WriteLine(" x x");
115 | else if (e > 1) Console.WriteLine(" x");
116 | else Console.WriteLine();
117 |
118 | if (e > 4) Console.WriteLine(" xxx x");
119 | else if (e > 1) Console.WriteLine(" x");
120 | else Console.WriteLine();
121 |
122 | if (e > 4) Console.WriteLine(" xxxxx x");
123 | else if (e > 1) Console.WriteLine(" x");
124 | else Console.WriteLine();
125 |
126 | if (e > 4) Console.WriteLine(" xxx x");
127 | else if (e > 1) Console.WriteLine(" x");
128 | else Console.WriteLine();
129 |
130 | if (e > 5) Console.WriteLine(" x x");
131 | else if (e > 1) Console.WriteLine(" x");
132 | else Console.WriteLine();
133 |
134 | if (e > 7) Console.WriteLine(" x x x x");
135 | else if (e > 6) Console.WriteLine(" x x x");
136 | else if (e > 5) Console.WriteLine(" x x");
137 | else if (e > 1) Console.WriteLine(" x");
138 | else Console.WriteLine();
139 |
140 | if (e > 7) Console.WriteLine(" x x x x");
141 | else if (e > 6) Console.WriteLine(" x x x");
142 | else if (e > 5) Console.WriteLine(" x x");
143 | else if (e > 1) Console.WriteLine(" x");
144 | else Console.WriteLine();
145 |
146 | if (e > 5) Console.WriteLine(" x x");
147 | else if (e > 1) Console.WriteLine(" x");
148 | else Console.WriteLine();
149 |
150 | if (e > 9) Console.WriteLine(" x x x");
151 | else if (e > 8) Console.WriteLine(" x x");
152 | else if (e > 1) Console.WriteLine(" x");
153 | else Console.WriteLine();
154 |
155 | if (e > 9) Console.WriteLine(" x x x");
156 | else if (e > 8) Console.WriteLine(" x x");
157 | else if (e > 1) Console.WriteLine(" x");
158 | else Console.WriteLine();
159 |
160 | if (e > 1) Console.WriteLine(" x");
161 | else Console.WriteLine();
162 |
163 | if (e > 1) Console.WriteLine(" x");
164 | else Console.WriteLine();
165 |
166 | if (e > 0) Console.WriteLine("xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
167 | else Console.WriteLine();
168 | Console.WriteLine();
169 |
170 | }
171 | Console.Write("The word: ");
172 |
173 | for (int i = 0; i < word.Length; ++i)
174 | {
175 | if (v[i])
176 | {
177 | Console.Write(" " + word[i] + " ");
178 | }
179 | else {
180 | Console.Write(" _ ");
181 | }
182 | }
183 | Console.WriteLine();
184 | }
185 |
186 | // printing final result
187 | if (done)
188 | {
189 | Console.WriteLine("You won!");
190 | }
191 | else {
192 | Console.WriteLine("You lost.");
193 | Console.WriteLine("The word was: " + word);
194 | }
195 | }
196 | else
197 | {
198 | Console.WriteLine("Sorry, no words like that.");
199 | }
200 |
201 | }
202 | }
203 | }
204 |
--------------------------------------------------------------------------------
/hangman/C#/Hangman/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Hangman")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Hangman")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("1769ed1b-d62a-45a7-ab21-3cbb2dde2180")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/hangman/C#/README.md:
--------------------------------------------------------------------------------
1 | To compile, you need Visual Studio or Mono installed.
2 |
3 | * Use Visual Studio to compile your project
4 | * Use command line: ```csc Hangman/Program.cs```
5 |
6 | To run, on the command line run the command ```mono Program.exe``` on Unix or ```.\Program.exe``` on Windows.
7 |
--------------------------------------------------------------------------------
/hangman/C++/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.exe
3 | *.out
4 |
--------------------------------------------------------------------------------
/hangman/C++/README.md:
--------------------------------------------------------------------------------
1 | To compile, you need GCC or Clang installed.
2 | The compiler must at a minimum support C++11.
3 |
4 | * gcc: ```g++ hangman/main.cpp```
5 | * clang: ```clang++ hangman/main.cpp```
6 |
7 | * To change the name of output file (a.out by default) ```g++ -o output_file_name main.cpp```
8 |
9 | To run, on the command line run the command ```./a.out``` on Unix or ```.\a.exe``` on Windows.
10 |
--------------------------------------------------------------------------------
/hangman/C++/hangman/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include