From 59ef296f043b237700d2cae0b4f6152a45dafef1 Mon Sep 17 00:00:00 2001 From: JJ27 <66833672+JJ27@users.noreply.github.com> Date: Thu, 25 Jun 2020 17:51:54 -0400 Subject: [PATCH 1/7] Create StringSlicer Problem Some practice with String Methods --- StringSlicer | 3 +++ .../chapter3/practice/StringSlicer.java | 11 +++++++++ .../chapter3/solutions/StringSlicer.java | 24 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 StringSlicer create mode 100644 src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java create mode 100644 src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java diff --git a/StringSlicer b/StringSlicer new file mode 100644 index 0000000..1700e11 --- /dev/null +++ b/StringSlicer @@ -0,0 +1,3 @@ +public class StringSlicer{ + public static +} diff --git a/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java b/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java new file mode 100644 index 0000000..5af2f4b --- /dev/null +++ b/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java @@ -0,0 +1,11 @@ +public class StringSlicer{ + /* + Use String Methods to convert the following strings to the results + a) "A Tale of Two Cities" -> "WO CIT" + b) "A Handmaid's Tale" -> "s" + c) "wE LoVe tO CoDe" -> "we love to cod" + */ + public static void main(String[] args){ + + } +} diff --git a/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java b/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java new file mode 100644 index 0000000..5954b6b --- /dev/null +++ b/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java @@ -0,0 +1,24 @@ +public class StringSlicer{ + /* + Use String Methods to convert the following strings to the results + a) "A Tale of Two Cities" -> "WO CIT" + b) "A Handmaid's Tale" -> "s" + c) "wE LoVe tO CoDe" -> "e love to code" + */ + public static void main(String[] args){ + //Initialize original strings + String s1 = "A Tale of Two Cities"; + String s2 = "A Handmaid's Tale"; + String s3 = "wE LoVe tO CoDe"; + + //Use substring + uppercase on the first one + System.out.println(s1.toUpperCase().substring(11,17)); + + //Use charAt for s2 + System.out.println(s2.charAt(11)); + + //Use the single-argument substring + lowercase + System.out.println(s3.toLowerCase().substring(1)); + //You can also use substring(1,13) + } +} From a035c5be9302510fb0c0f49437d4f6b922e45b13 Mon Sep 17 00:00:00 2001 From: JJ27 <66833672+JJ27@users.noreply.github.com> Date: Thu, 25 Jun 2020 18:27:48 -0400 Subject: [PATCH 2/7] Update StringSlicer.java --- .../beginner/chapter3/solutions/StringSlicer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java b/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java index 5954b6b..05c379e 100644 --- a/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java +++ b/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java @@ -19,6 +19,6 @@ public static void main(String[] args){ //Use the single-argument substring + lowercase System.out.println(s3.toLowerCase().substring(1)); - //You can also use substring(1,13) + //You can also use substring(1,15) } } From 98261ac6cebab6d7816b97b5a3b2ec3385f39b0e Mon Sep 17 00:00:00 2001 From: JJ27 <66833672+JJ27@users.noreply.github.com> Date: Thu, 25 Jun 2020 18:37:45 -0400 Subject: [PATCH 3/7] Add package and move instructions Added package Moved instructions to correct location --- .../chapter3/practice/StringSlicer.java | 17 ++++++++++------- .../chapter3/solutions/StringSlicer.java | 14 ++++++++------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java b/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java index 5af2f4b..9ff2cbf 100644 --- a/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java +++ b/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java @@ -1,11 +1,14 @@ +package com.codefortomorrow.beginner.chapter3.practice; + +/* + * Use String Methods to convert the following strings to the results + * a) "A Tale of Two Cities" -> "WO CIT" + * b) "A Handmaid's Tale" -> "s" + * c) "wE LoVe tO CoDe" -> "e love to code" + */ + public class StringSlicer{ - /* - Use String Methods to convert the following strings to the results - a) "A Tale of Two Cities" -> "WO CIT" - b) "A Handmaid's Tale" -> "s" - c) "wE LoVe tO CoDe" -> "we love to cod" - */ public static void main(String[] args){ - + //Write Code here } } diff --git a/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java b/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java index 05c379e..1bc2fbb 100644 --- a/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java +++ b/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java @@ -1,10 +1,12 @@ +package com.codefortomorrow.beginner.chapter3.solutions; + +/* + * Use String Methods to convert the following strings to the results + * a) "A Tale of Two Cities" -> "WO CIT" + * b) "A Handmaid's Tale" -> "s" + * c) "wE LoVe tO CoDe" -> "e love to code" + */ public class StringSlicer{ - /* - Use String Methods to convert the following strings to the results - a) "A Tale of Two Cities" -> "WO CIT" - b) "A Handmaid's Tale" -> "s" - c) "wE LoVe tO CoDe" -> "e love to code" - */ public static void main(String[] args){ //Initialize original strings String s1 = "A Tale of Two Cities"; From 211970e5fdc8929fdab66d7560592315b1fb1061 Mon Sep 17 00:00:00 2001 From: JJ27 <66833672+JJ27@users.noreply.github.com> Date: Thu, 25 Jun 2020 18:41:13 -0400 Subject: [PATCH 4/7] Delete Text File Deleted a text file that shouldn't be there --- StringSlicer | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 StringSlicer diff --git a/StringSlicer b/StringSlicer deleted file mode 100644 index 1700e11..0000000 --- a/StringSlicer +++ /dev/null @@ -1,3 +0,0 @@ -public class StringSlicer{ - public static -} From e6eacd2b31bbdb138111c2e7df9e8e3000d3f48d Mon Sep 17 00:00:00 2001 From: Rebecca Dang <35876322+phrdang@users.noreply.github.com> Date: Fri, 26 Jun 2020 00:44:40 -0700 Subject: [PATCH 5/7] Update Practice Problem Guidelines Added instructions on how the PR workflow works for C4T. Also changed Google Form to be only for those without GitHub accounts. --- README.md | 110 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 5d350a9..04e6ee9 100644 --- a/README.md +++ b/README.md @@ -50,27 +50,54 @@ Please follow the following guidelines when creating or finding practice problem If you have questions, send a message to #questions on the teachers Discord. ## Follow good programming style. +### Install Linters +This will save you time because when you submit a pull request (PR) on GitHub, we check for good programming style. Your PR will not be approved unless it passes those style checks. Also, linters basically enforce all of the style rules that we discuss below, so you basically can just skip to the next section (Follow the C4T practice and solution problem format). + +* Java: Install checkstyle (SonarLint recommended as well) +* Python: Install flake8 (pylint recommended as well) +* HTML/CSS: Install SonarLint (recommended) + +This should go without saying, but actually use the linters! If you see errors/problems/warnings, address them, don’t ignore them and keep going! + +**Note:** We highly recommend that you use [Visual Studio Code](https://code.visualstudio.com/download), because it has a lot of useful extensions you can install with a few clicks (including the linters mentioned above). It also has great Version Control System (VCS) integration and extensions. + +### Whitespace * Indent properly. * Make sure there are spaces between binary operators, parentheses, curly braces, etc. when applicable. (For method/function calls, there should not be a space between the method/function name and the parentheses.) -* Name files so that they are representative of what the program is about. + * For HTML, attributes should not have spaces between the attribute name, equal sign, and attribute value +* Leave empty lines where appropriate to increase readability + +### Naming +* Name files so that they are representative of what the program is about. File names are also the name of the practice problem. * Avoid naming files after concepts, like “Arrays.java” + * Java: Use class naming conventions to name files. For example, HelloWorld.java rather than helloWorld.java or hello_world.java or something else + * Python: Use snake case to name files. For example, hello_world.py rather than HelloWorld.py or helloWorld.py or something else * Name variables/methods/functions descriptively, and follow your language’s conventions. - * Java: camelCase for regular variables, snake case (and uppercase) for constants - * Python: Snake case for regular variables, snake case (and uppercase) for constants + * Java: camelCase for regular variables, snake case (and uppercase) for constants + * Python: Snake case for regular variables, snake case (and uppercase) for constants + +### Reduce complexity * If a line of code is very long, separate it into 2+ lines (e.g. for long lists/arrays, long print statements, etc.) -* Leave whitespace where appropriate to increase readability. -* Add comments to explain parts of your code. +* Add comments to explain parts of your code +* Break up the program into methods/functions if applicable and if the students have learned about methods/functions at that point in time. ## Follow the C4T practice and solution problem format. -* All code filed under `practice` should be templates. Templates may include things like an empty class and main method. They must include a multi-line comment with the full instructions that are also displayed on Thinkific at the top of the program. -* All code filed under `solutions` should be solutions. Solutions should include the full instructions at the top of the file and then a possible solution to the problem. -* The practice template and solution should have *the same file name.* -* For Java teachers: Make sure that you have the correct package statement as the first line of your code. - -## Thoroughly test your solution. Make sure it works as intended. +* Make sure you put the file(s) in the right directories. + * All code filed under “practice” should be templates. + * Templates may include things like an empty class and main method. + * They must include a multi-line comment with the title of the practice problem AND the full instructions for the problem. + * All code filed under “solutions” should be solutions. + * Solutions should include the practice problem title AND full instructions at the top of the file (exact same comment as in the practice template file) and then a (possible) solution to the problem. +* The practice template and solution should have the same file name. +* Java: Make sure that you have the correct package statement as the first line of your code. + +## Testing +* Thoroughly test your solution. Make sure it works as intended. + * Try to break your program! Don’t just give input you know will work. * Hundreds of students and ~50 teachers could potentially see and use your work. Please make sure that it works! -## Make sure that the problem is doable for the skill level of your students. +## Check the content. +* Make sure that the problem is doable for the skill level of your students. * Check Thinkific to see if the concepts that you need to solve the problem have been covered already. * Be aware of how long your own class takes on other practice problems. * Practice problems shouldn’t take several hours/days. @@ -81,32 +108,35 @@ If you have questions, send a message to #questions on the teachers Discord. * If you found it in a book, cite the full title and author. ## Submit practice problem(s). -### Overall directions no matter which option you choose: -* Make sure you push to the correct folder and repository. -* Instructions should be formatted as follows: - -> **Practice:** [full instructions] -> -> **Practice template:** practice/[FileName].extension -> -> **Solution:** solutions/[FileName].extension - -To submit a problem, you have 3 options: - -### (1) Pushing to GitHub -1. Dm Rebecca Dang on the Teachers Discord with your GitHub username and course(s) you’re teaching to be invited to the C4T GitHub organization -2. Clone the repo. -3. Create your own branch. Name it appropriately. -4. Push your branch to remote. -5. Mention @Curriculum Development on the Teachers Discord that you have pushed your branch. Be sure to tell us what the name of your branch is! -6. If Curr-Dev approves, you have permission to merge your branch with master. - -### (2) Making a pull request -[See this help article](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests) - -### (3) Email C4T Curriculum Development -1. Email [c4t.curriculum@gmail.com](mailto:c4t.curriculum@gmail.com) with all necessary info (e.g. instructions, practice template file, solution file). -2. Mention @Curriculum Development on the Teachers Discord that you have emailed us please! - -Thank you teachers for following these guidelines and helping us build a problem base! +### Option 1: Use GitHub +***Note 1:** If you choose option 1, we assume you know basic Git, e.g. committing, pushing, pulling, branching, merging, etc. If you want to learn the basic Git you need to contribute, we recommend watching [this entire playlist.](https://www.youtube.com/watch?v=3RjQznt-8kE&list=PL4cUxeGkcC9goXbgTDQ0n_4TBzOO0ocPR&index=1)* + +***Note 2:** If you want an overview of the Pull Request (PR) workflow we are using, read these articles.* + +1. Send your GitHub username to a Curriculum Development member and ask them to add you as an outside collaborator on the repository or repositories that you want to contribute to. +2. Clone or fork the official C4T repository. + * All repositories can be found here: https://github.com/code-for-tomorrow + * [How to Clone](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) + * [How to Fork](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) +3. Work on the practice problems locally. + * If you cloned the repo, make sure you create and checkout a new branch. **DO NOT MAKE EDITS ON THE MASTER BRANCH.** + * If you forked the repo, you’re free to work on the master branch or make your own branches (though that is kinda unnecessary). + * [Git Branches Tutorial](https://www.atlassian.com/git/tutorials/using-branches) +4. Push your local branch to remote. + * [How to Push](https://help.github.com/en/github/using-git/pushing-commits-to-a-remote-repository) +5. Make a pull request to merge your branch with the master branch of the official C4T repo. + * Make sure that the title of your pull request is descriptive but concise. + * In the description part of your pull request, you should specify the following: + * Your full name (if it’s not clear from your GitHub profile) + * Chapter # and section name that this problem should go under (for example, Ch. 1 Intro to Python, Section: Comments) + * [How to Create a Pull Request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request) +6. Mention @Curriculum Development on the Teachers Discord that you’ve submitted a PR. +7. Monitor the status of your Pull Request on GitHub. + * It’s possible that the Curriculum Development team will Request Changes, in which case you will need to commit those changes before your PR will be approved and merged into the official master branch. + +### Option 2: Use the Google Form +Submit a problem [here](https://forms.gle/hDWrPRG3HuAgUdCJ9) if you don’t have a GitHub account. + + +**Thank you teachers for following these guidelines and helping us build a problem base!** From d8739a7dfe954e7f2fc591e0a3731920390dcd10 Mon Sep 17 00:00:00 2001 From: JJ27 <66833672+JJ27@users.noreply.github.com> Date: Fri, 26 Jun 2020 09:41:58 -0400 Subject: [PATCH 6/7] Fix Reviewdog Changes Fix style errors --- .../beginner/chapter3/practice/StringSlicer.java | 2 +- .../beginner/chapter3/solutions/StringSlicer.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java b/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java index 9ff2cbf..4219743 100644 --- a/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java +++ b/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java @@ -7,7 +7,7 @@ * c) "wE LoVe tO CoDe" -> "e love to code" */ -public class StringSlicer{ +public class StringSlicer { public static void main(String[] args){ //Write Code here } diff --git a/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java b/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java index 1bc2fbb..7e301e9 100644 --- a/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java +++ b/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java @@ -6,15 +6,16 @@ * b) "A Handmaid's Tale" -> "s" * c) "wE LoVe tO CoDe" -> "e love to code" */ -public class StringSlicer{ - public static void main(String[] args){ +public class StringSlicer { + //Solution Code Below + public static void main(String[] args) { //Initialize original strings String s1 = "A Tale of Two Cities"; String s2 = "A Handmaid's Tale"; String s3 = "wE LoVe tO CoDe"; //Use substring + uppercase on the first one - System.out.println(s1.toUpperCase().substring(11,17)); + System.out.println(s1.toUpperCase().substring(11, 17)); //Use charAt for s2 System.out.println(s2.charAt(11)); From 1a6c092a3cb2c6d5e4a3533e2af975673b4f863c Mon Sep 17 00:00:00 2001 From: Rebecca Dang Date: Fri, 26 Jun 2020 10:33:41 -0700 Subject: [PATCH 7/7] Fix style (whitespace for methods, comments) --- .../chapter3/practice/StringSlicer.java | 14 ++++++++++ .../chapter3/solutions/StringSlicer.java | 26 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java create mode 100644 src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java diff --git a/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java b/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java new file mode 100644 index 0000000..b8b82d4 --- /dev/null +++ b/src/com/codefortomorrow/beginner/chapter3/practice/StringSlicer.java @@ -0,0 +1,14 @@ +package com.codefortomorrow.beginner.chapter3.practice; + +/* + * Use String Methods to convert the following strings to the results + * a) "A Tale of Two Cities" -> "WO CIT" + * b) "A Handmaid's Tale" -> "s" + * c) "wE LoVe tO CoDe" -> "e love to code" + */ + +public class StringSlicer { + public static void main(String[] args) { + // Write Code here + } +} diff --git a/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java b/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java new file mode 100644 index 0000000..ad34343 --- /dev/null +++ b/src/com/codefortomorrow/beginner/chapter3/solutions/StringSlicer.java @@ -0,0 +1,26 @@ +package com.codefortomorrow.beginner.chapter3.solutions; + +/* + * Use String Methods to convert the following strings to the results + * a) "A Tale of Two Cities" -> "WO CIT" + * b) "A Handmaid's Tale" -> "s" + * c) "wE LoVe tO CoDe" -> "e love to code" + */ +public class StringSlicer { + public static void main(String[] args) { + // Initialize original strings + String s1 = "A Tale of Two Cities"; + String s2 = "A Handmaid's Tale"; + String s3 = "wE LoVe tO CoDe"; + + // Use substring + uppercase on the first one + System.out.println(s1.toUpperCase().substring(11, 17)); + + // Use charAt for s2 + System.out.println(s2.charAt(11)); + + // Use the single-argument substring + lowercase + System.out.println(s3.toLowerCase().substring(1)); + // You can also use substring(1,15) + } +}