diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..5feb601
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ae3c172
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/.project b/.project
new file mode 100644
index 0000000..b93b8c0
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ programming-methodology-java
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/problem-set/CountEvenNumbers.java b/problem-set/CountEvenNumbers.java
new file mode 100644
index 0000000..77d8d88
--- /dev/null
+++ b/problem-set/CountEvenNumbers.java
@@ -0,0 +1,33 @@
+// importing console program
+import acm.program.ConsoleProgram;
+
+/*
+ * This program reads integers from user until he enters -1 and counts how many
+ * even numbers are among the entered numbers.
+ */
+
+public class CountEvenNumbers extends ConsoleProgram {
+
+ // This global variable is the indicator that we should stop reading integers
+ // form user and print the output
+ private final static int SENTINEL = -1;
+
+ public void run() {
+ // The variable which stores total number of even numbers
+ int evens = 0;
+ // Reading integers from user and increment 'even' variable if the given number
+ // is even
+ while (true) {
+ int input = readInt("Enter the number or -1 for stop");
+ // Check if the number is SENTINEL and stop reading if it is
+ if (input == SENTINEL) {
+ break;
+ }
+ if (input % 2 == 0) {
+ evens++;
+ }
+ }
+ // Printing the result
+ println("The total number of even numbers are: " + evens);
+ }
+}
diff --git a/problem-set/Frendliest.java b/problem-set/Frendliest.java
new file mode 100644
index 0000000..d7530a1
--- /dev/null
+++ b/problem-set/Frendliest.java
@@ -0,0 +1,50 @@
+
+// Importing map and hashmap
+import java.util.HashMap;
+import java.util.Map;
+//Importing console program
+import acm.program.ConsoleProgram;
+
+public class Frendliest extends ConsoleProgram {
+ // This program prints the person who has the highest number of friends
+ public void run() {
+ setFont("-20");
+ Map friendlist = new HashMap<>();
+ readPairs(friendlist);
+ printMostPopularPerson(friendlist);
+ }
+
+ // This method searches the most popular person in map and prints his/her name in console
+ private void printMostPopularPerson(Map friendlist) {
+ String person = "";
+ int max = 0;
+ for(String key : friendlist.keySet()) {
+ if(friendlist.get(key) > max) {
+ max = friendlist.get(key);
+ person = key;
+ }
+ }
+ println(person + " has the highest number of friends!");
+ }
+
+ // This method reads string pairs from console and stores the number of friends for each person
+ // in map. Each pair contains two people's names.
+ private void readPairs(Map friendlist) {
+ while(true) {
+ String friend = readLine("Enter the first person's name or [enter] to end: ");
+ if(friend.equals("")) {
+ break;
+ }
+ String person = readLine("Enter the second person's name or [enter] to end: ");
+ if(person.equals("")) {
+ break;
+ }
+ if(friendlist.containsKey(person)) {
+ friendlist.put(person, friendlist.get(person) + 1);
+ } else {
+ friendlist.put(person, 1);
+ }
+ println(friend + " is a friend of " + person);
+ }
+ }
+}
diff --git a/problem-set/Friendlist.md b/problem-set/Friendlist.md
new file mode 100644
index 0000000..e939bba
Binary files /dev/null and b/problem-set/Friendlist.md differ
diff --git a/problem-set/MostFrequentSymbol.java b/problem-set/MostFrequentSymbol.java
new file mode 100644
index 0000000..733be86
--- /dev/null
+++ b/problem-set/MostFrequentSymbol.java
@@ -0,0 +1,65 @@
+// Importing console program
+import acm.program.ConsoleProgram;
+
+public class MostFrequentSymbol extends ConsoleProgram {
+
+ // This program reads string from console and prints the most frequent symbol in it
+ public void run() {
+ while(true) {
+ String input = readLine("Enter the string: ");
+ // Initialising array with 26 so that each index has frequency value of the corresponding
+ // character.
+ int[] frequencies = new int[26];
+ countFrequencies(frequencies, input);
+ char result = findMostFrequentSymbol(frequencies, input);
+ println("The most frequent symbol is: " + result);
+ }
+ }
+
+ // This method searches and returns the most frequent character
+ private char findMostFrequentSymbol(int[] frequencies, String input) {
+ int maxFreq = 0;
+ char result = 'a';
+ for(int i = 0; i < frequencies.length; i++) {
+ if(maxFreq < frequencies[i]) {
+ result = (char)('a' + i);
+ maxFreq = frequencies[i];
+ }
+ }
+ return result;
+ }
+
+ // This method counts the frequencies of the characters and stores them in array
+ private void countFrequencies(int[] frequencies, String input) {
+ for(int i = 0; i < input.length(); i++) {
+ char curChar = input.charAt(i);
+ int index = -1;
+ if(isUpperCase(curChar)) {
+ index = curChar - 'A';
+ } else if(isLowerCase(curChar)){
+ index = curChar - 'a';
+ } else {
+ continue;
+ }
+ frequencies[index]++;
+ }
+ }
+
+ // This method checks if the character is lower case or not
+ private boolean isLowerCase(char curChar) {
+ if(curChar >= 'a' && curChar <= 'z') {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ // This method checks if the character is upper case or not
+ private boolean isUpperCase(char curChar) {
+ if(curChar >= 'A' && curChar <= 'Z') {
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/problem-set/MostFrequentSymbol.md b/problem-set/MostFrequentSymbol.md
new file mode 100644
index 0000000..e69de29
diff --git a/problem-set/Robot.java b/problem-set/Robot.java
new file mode 100644
index 0000000..2f3fdce
--- /dev/null
+++ b/problem-set/Robot.java
@@ -0,0 +1,73 @@
+
+// Importing graphics program.
+import acm.program.GraphicsProgram;
+// Import for colours.
+import java.awt.Color;
+// Import for rectangles.
+import acm.graphics.GRect;
+
+public class Robot extends GraphicsProgram {
+
+ // Some useful constants
+ private static final int FACE_LENGTH = 300;
+ private static final int FACE_WIDTH = 400;
+ private static final int EYE_SIZE = 50;
+ private static final int NECK_WIDTH = 100;
+ private static final int NECK_HEIGHT = 300;
+ private static final int MOUTH_WIDTH = 100;
+ private static final int MOUTH_HEIGHT = 20;
+ private static final int MOUTH_OFFSET = 70;
+
+ public void run() {
+ drawRobot();
+ }
+
+ // This problem can be divided into 4 sub-problems.
+ private void drawRobot() {
+ drawNeck();
+ drawFace();
+ drawEyes();
+ drawMouth();
+ }
+
+ // This method draws the face of the robot. Robot has gray rectangle face.
+ private void drawFace() {
+ GRect face = new GRect(getWidth() / 2 - FACE_WIDTH / 2, getHeight() / 2 - FACE_LENGTH / 2, FACE_WIDTH,
+ FACE_LENGTH);
+ face.setFilled(true);
+ face.setFillColor(Color.LIGHT_GRAY);
+ add(face);
+ }
+
+ // This method draws the eyes of the robot. Robot has round black eyes.
+ private void drawEyes() {
+ // Lets create one universal method in order to not repeat the code.
+ drawOneEye(getWidth() / 2 - FACE_WIDTH / 3);
+ drawOneEye(getWidth() / 2 + FACE_WIDTH / 3 - EYE_SIZE);
+ }
+
+ // This method takes the eye width as a parameter and draws black eye with that width.
+ private void drawOneEye(int width) {
+ GRect eye = new GRect(width, getHeight() / 2 - FACE_LENGTH / 6, EYE_SIZE, EYE_SIZE);
+ eye.setFilled(true);
+ eye.setColor(Color.BLACK);
+ add(eye);
+ }
+
+ // This method draws the mouth of the robot. Robot has black rectangle mouth.
+ private void drawMouth() {
+ GRect mouth = new GRect(getWidth() / 2 - MOUTH_WIDTH / 2, getHeight() / 2 + MOUTH_OFFSET,
+ MOUTH_WIDTH, MOUTH_HEIGHT);
+ mouth.setFilled(true);
+ mouth.setColor(Color.BLACK);
+ add(mouth);
+ }
+
+ // This method draws the neck of the robot. Robot has gray rectangle neck.
+ private void drawNeck() {
+ GRect neck = new GRect(getWidth() / 2 - NECK_WIDTH / 2, getHeight() - NECK_HEIGHT, NECK_WIDTH, NECK_HEIGHT);
+ neck.setFilled(true);
+ neck.setFillColor(Color.LIGHT_GRAY);
+ add(neck);
+ }
+}
diff --git a/problem-set/Robot.md b/problem-set/Robot.md
new file mode 100644
index 0000000..ada9086
--- /dev/null
+++ b/problem-set/Robot.md
@@ -0,0 +1,76 @@
+#Robot
+
+## ამოცანის პირობა:
+დახატეთ რობოტის სახე კანვასზე.
+
+## ამოხსნა:
+პირველი რიგში უნდა მოვიფიქროთ ამ ამოცანის კარგი დეკომპოზიცია. დეკომპოზიცია ძალიან გვეხმარება, განსაკუთრებით როცა საქმე გრაფიკულ პროგრამასთან გვაქვს, ვინაიდან დეკომპოზიციის გარეშე ხშირად მოგვიწევს ერთი და იმავე კოდის ბევრჯერ დაწერა.
+ამ ამოცანისთვის გამოვიყენოთ შემდეგი დეკომპოზიცია: დავხატოთ კისერი, სახე, თვალები და პირი.
+
+მთავარი მეთოდი მიიღებს ამგვარ სახეს:
+
+private void drawRobot() {
+ drawNeck();
+ drawFace();
+ drawEyes();
+ drawMouth();
+}
+
+მას შემდეგ, რაც ამოცანა დავყავით ქვეამოცანებად, ახლა ვიფიქროთ თითოეულის იმპლემენტაციაზე.
+
+### დავიწყოთ drawNeck() მეთოდით:
+
+private void drawNeck() {
+ GRect neck = new GRect(getWidth() / 2 - NECK_WIDTH / 2, getHeight() - NECK_HEIGHT, NECK_WIDTH, NECK_HEIGHT);
+ neck.setFilled(true);
+ neck.setFillColor(Color.LIGHT_GRAY);
+ add(neck);
+}
+
+ამ მეთოდით კანვასზე დაიხატება მართკუთხედი. კისერი უნდა დავხატოთ კანვასზე ჰორიზონტალურად გათანაბრებულად, ანუ მარჯვენა და მარცხენა კანვასის კიდეებამდე დაშორება უნდა იყოს თანაბარი ნებისმიერი კანვასის ზომისათვის, ამიტომაც აუცილებელია, რომ მართკუთხედის მდებაორება დამოკიდებული გავხადოთ getWidth() ცვლადზე, რომელიც აღნიშნავს კანვასის სიგანეს. ასევე კოდის ადვილად შეცვლის შესაძლებლობის შესანარჩუნებლად კარგი იქნება თუ გამოვიყენებთ კონსტანტებს კისრის ზომებისთვის. ამ შემთხვევაში ეს კონსტანტებია NECK_WIDTH და NECK_HEIGHT, რომლებიც აღნიშნავენ კისრის სიგანესა და სიმაღლეს. GRect neck არის მართკუთხედის ობიექტი, რომელსაც გააჩნია ორნაირი კონსტრუქტორი (ანუ ორნაირად შეგვიძლია აღვწეროთ). პირველი ვარიანტი არის ის რაც წერია, ანუ გადავცეთ სიგრძე/სიგანე/x/y და ასევე შეგვეძლო აღწერისას მხოლოდ სიგრძე/სიგანე გადაგვეცა, თუმცა ამ შემთხვევაში add-ში მოგვიწევდა კოორდინატების გადაცემა add(neck, x, y), ხოლო თუ არ გადავცემდით, დეფოლტად 0,0 კოორდინატებზე დახატავდა მართკუთხედს. neck.setFilled(true) - ეს ხაზი უზრუნველყოფს, რომ მართკუთხედის ობიექტს ჰქონდეს შიგთავსი. neck.setFillColor(Color.LIGHT_GRAY - ხოლო ეს ხაზი კი მართკუთხედის შიგთავსს აფერადებს იმ ფრად, რომელსაც გადავცემთ (ჩვენს შემთხვევაში LIGHT_GRAY). add არის ობიექტის კანვასზე გამოსაჩენი ბრძანება, მის გარეშე ობიექტი კანვასზე არ დაიხატება.
+
+### drawFace() მეთოდი:
+
+private void drawFace() {
+ GRect face = new GRect(getWidth() / 2 - FACE_WIDTH / 2, getHeight() / 2 - FACE_LENGTH / 2, FACE_WIDTH,
+ FACE_LENGTH);
+ face.setFilled(true);
+ face.setFillColor(Color.LIGHT_GRAY);
+ add(face);
+}
+
+ამ მეთოდით კანვასზე დაიხატება რობოტის სახე. სახე, ისევე როგორც კისერი, ჰორიზონტალურად უნდა იყოს გათანაბრებული, ამიტომ მისი x კოორდინატიც getWidth() ცვლადზე დამოკიდებული უნდა იყოს. ასევე აქაც უნდა გამოვიყენოთ შესაბამისი კონსტანტები, გავაფერადოთ და საბოლოოდ დავამატოთ კანვასზე.
+
+### drawEyes() მეთოდი:
+private void drawEyes() {
+ drawOneEye(getWidth() / 2 - FACE_WIDTH / 3);
+ drawOneEye(getWidth() / 2 + FACE_WIDTH / 3 - EYE_SIZE);
+}
+
+ეს მეთოდი ხატავს ორ თვალს რობიტის სახეზე, რომლებიც უნდა იყოს რობოტის სახის ზომებსა და კანვასის სიგანეზე დამოკიდებული. აქ მნიშვნელოვანი დეტალია უნივერსალური მეთოდის გაკეთება. ვინაიდან ორივე თვალის დახატვა თითქმის ერთი და იგივე კოდის, ჩვენ შეგვიძლია ცალკე მეთოდი გავაკეთოთ და ორჯერ გამოვიძახოთ ნაცვლად იმისა, რომ ერთიდაიგივე კოდი ორჯერ დავწეროთ. ჯერ უნდა დავფიქრდეთ იმაზე თუ რა განასხვავებს თვალებს. თვალები ზუსტად ერთიდაიგივეა გარდა მათი მდებარეობისა. განსხვავებული აქვთ მხოლო x კოორდინატი. ამიტომაც შევქმანთ მეთოდი რომელსაც გადავცემთ x კოორდინატს, როგორც ცვლადს, და ეს მეთოდის დახატავს თვალს ამ x კოორდინატზე. ეს მეთოდი გამოიყურება ასე:
+
+### drawOneEye(int x) მეთოდი:
+
+private void drawOneEye(int x) {
+ GRect eye = new GRect(width, getHeight() / 2 - FACE_LENGTH / 6, EYE_SIZE, EYE_SIZE);
+ eye.setFilled(true);
+ eye.setColor(Color.BLACK);
+ add(eye);
+}
+
+
+### და ბოლოს drawMouth() მეთოდი:
+
+private void drawMouth() {
+ GRect mouth = new GRect(getWidth() / 2 - MOUTH_WIDTH / 2, getHeight() / 2 + MOUTH_OFFSET,
+ MOUTH_WIDTH, MOUTH_HEIGHT);
+ mouth.setFilled(true);
+ mouth.setColor(Color.BLACK);
+ add(mouth);
+}
+
+ეს მეთოდი კანვასზე ხატავს რობოტის პირს, მართკუთხედს. ისევე როგორ ყველა სხვა ობიექტი ესეც, უნდა იყოს ჰორიზონტალურად შუაშია კანვაზე და ასევე რობოტის სახის შუაში, ამიტომაც აქაც საჭიროა ამ ცვლადებზე დამოკიდებული მართკუხედის ობიექტის შექმნა.
+
+## შესაძლო ხარვეზები იმპლემენტაციისას:
+1. კანვასის ზომების ცვლადების (getWidth() და getHeight()) გარეშე ობიექტების მდებარეობის განსაზღვრა, რაც გამოიწვევს იმას, რომ კოდის გამოვა ნაკლებად კითხვადი, მოგვიწევს ბევრი წვალება კოორდინატების ზუსტად შესარჩევად და სხვა ზომის კანვასზე რობოტის სახე არასწორად არ იქნება ისეთი პროპორცოული, როგორიც იყო თავდაპირველად.
+2. დეკომპოზიციის გარეშე დაწერა. ამ შემთხვევაში მოგვიწევს მთლიანი კოდის ერთ მეთოდში დაწერა, რაც მას გახდის ძნელად წასაკითხსა და გასაგებს. ამასთან რთული იქნება კოდში შეცდომის პოვნა.
\ No newline at end of file