├── JavaAppLesson001 ├── JavaEE001.md └── org │ └── csystem │ ├── app │ ├── App.java │ └── samples │ │ ├── centrallimittheorem │ │ ├── CentralLimitTheoremSimulation.java │ │ └── CentralLimitTheoremSimulationApp.java │ │ ├── commandpromptapp │ │ ├── CommandPrompt.java │ │ └── CommandPromptApp.java │ │ ├── companyapp │ │ ├── CompanyApp.java │ │ ├── Employee.java │ │ ├── HumanResources.java │ │ ├── Manager.java │ │ ├── ProjectWorker.java │ │ ├── SalesManager.java │ │ └── Worker.java │ │ ├── dateapp │ │ ├── DateTestApp.java │ │ ├── DateUtil.java │ │ └── DateUtilTestApp.java │ │ ├── examsimulationapp │ │ ├── ExamSimulation.java │ │ └── ExamSimulationApp.java │ │ ├── lottaryapp │ │ ├── Lottary.java │ │ └── LottaryTest.java │ │ ├── parserapp │ │ ├── CharArraySource.java │ │ ├── ISource.java │ │ ├── Parser.java │ │ ├── ParserApp.java │ │ └── StringSource.java │ │ ├── randomobjectsgeneratorapp │ │ ├── RandomObjectsGenerator.java │ │ └── RandomObjectsGeneratorApp.java │ │ └── sentenceterminalapp │ │ ├── SentenceTerminal.java │ │ └── SentenceTerminalApp.java │ ├── math │ ├── Complex.java │ ├── Rational.java │ ├── RationalException.java │ ├── RationalExceptionStatus.java │ └── geometry │ │ ├── AnalyticalCircle.java │ │ ├── Circle.java │ │ ├── Point.java │ │ └── PointF.java │ └── util │ ├── ArrayUtil.java │ ├── Console.java │ ├── ConsoleUtil.java │ ├── IntValue.java │ ├── NumberUtil.java │ ├── Pair.java │ ├── StringSplitOptions.java │ ├── StringUtil.java │ ├── Triple.java │ ├── Unit.java │ ├── collection │ └── CSDArrayList.java │ └── datetime │ ├── Date.java │ ├── DateTime.java │ ├── DateTimeException.java │ ├── DayOfWeek.java │ ├── Month.java │ └── Time.java ├── JavaAppLesson002 ├── JavaEE002.md └── org │ └── csystem │ ├── app │ ├── App.java │ └── samples │ │ ├── centrallimittheorem │ │ ├── CentralLimitTheoremSimulation.java │ │ └── CentralLimitTheoremSimulationApp.java │ │ ├── commandpromptapp │ │ ├── CommandPrompt.java │ │ └── CommandPromptApp.java │ │ ├── companyapp │ │ ├── CompanyApp.java │ │ ├── Employee.java │ │ ├── HumanResources.java │ │ ├── Manager.java │ │ ├── ProjectWorker.java │ │ ├── SalesManager.java │ │ └── Worker.java │ │ ├── dateapp │ │ ├── DateTestApp.java │ │ ├── DateUtil.java │ │ └── DateUtilTestApp.java │ │ ├── examsimulationapp │ │ ├── ExamSimulation.java │ │ └── ExamSimulationApp.java │ │ ├── lottaryapp │ │ ├── Lottary.java │ │ └── LottaryTest.java │ │ ├── parserapp │ │ ├── CharArraySource.java │ │ ├── ISource.java │ │ ├── Parser.java │ │ ├── ParserApp.java │ │ └── StringSource.java │ │ ├── randomobjectsgeneratorapp │ │ ├── RandomObjectsGenerator.java │ │ └── RandomObjectsGeneratorApp.java │ │ └── sentenceterminalapp │ │ ├── SentenceTerminal.java │ │ └── SentenceTerminalApp.java │ ├── math │ ├── Complex.java │ ├── Rational.java │ ├── RationalException.java │ ├── RationalExceptionStatus.java │ └── geometry │ │ ├── AnalyticalCircle.java │ │ ├── Circle.java │ │ ├── Point.java │ │ └── PointF.java │ └── util │ ├── ArrayUtil.java │ ├── Console.java │ ├── ConsoleUtil.java │ ├── IntValue.java │ ├── NumberUtil.java │ ├── Pair.java │ ├── StringSplitOptions.java │ ├── StringUtil.java │ ├── Triple.java │ ├── Unit.java │ ├── collection │ └── CSDArrayList.java │ └── datetime │ ├── Date.java │ ├── DateTime.java │ ├── DateTimeException.java │ ├── DayOfWeek.java │ ├── Month.java │ └── Time.java ├── JavaAppLesson003 ├── CreatingJarFilesViaIntelliJIDE.md ├── JavaEE003.md ├── Libraries │ └── IntelliJ │ │ ├── Libraries │ │ ├── Libraries.iml │ │ ├── MathLib │ │ │ ├── MathLib.iml │ │ │ └── src │ │ │ │ └── org │ │ │ │ └── csystem │ │ │ │ └── math │ │ │ │ ├── Complex.java │ │ │ │ ├── Rational.java │ │ │ │ ├── RationalException.java │ │ │ │ ├── RationalExceptionStatus.java │ │ │ │ └── geometry │ │ │ │ ├── AnalyticalCircle.java │ │ │ │ ├── Circle.java │ │ │ │ ├── Point.java │ │ │ │ └── PointF.java │ │ ├── UtilLib │ │ │ ├── UtilLib.iml │ │ │ └── src │ │ │ │ └── org │ │ │ │ └── csystem │ │ │ │ └── util │ │ │ │ ├── ArrayUtil.java │ │ │ │ ├── CommandLineUtil.java │ │ │ │ ├── Console.java │ │ │ │ ├── ConsoleUtil.java │ │ │ │ ├── IntValue.java │ │ │ │ ├── NumberUtil.java │ │ │ │ ├── Pair.java │ │ │ │ ├── StringSplitOptions.java │ │ │ │ ├── StringUtil.java │ │ │ │ ├── Triple.java │ │ │ │ └── Unit.java │ │ └── out │ │ │ └── production │ │ │ ├── MathLib │ │ │ └── org │ │ │ │ └── csystem │ │ │ │ └── math │ │ │ │ ├── Complex.class │ │ │ │ ├── Rational.class │ │ │ │ ├── RationalException.class │ │ │ │ ├── RationalExceptionStatus.class │ │ │ │ └── geometry │ │ │ │ ├── AnalyticalCircle.class │ │ │ │ ├── Circle.class │ │ │ │ ├── Point.class │ │ │ │ └── PointF.class │ │ │ └── UtilLib │ │ │ └── org │ │ │ └── csystem │ │ │ └── util │ │ │ ├── ArrayUtil.class │ │ │ ├── CommandLineUtil.class │ │ │ ├── Console$Error.class │ │ │ ├── Console.class │ │ │ ├── ConsoleUtil.class │ │ │ ├── IntValue.class │ │ │ ├── NumberUtil.class │ │ │ ├── Pair.class │ │ │ ├── StringSplitOptions.class │ │ │ ├── StringUtil.class │ │ │ ├── Triple.class │ │ │ └── Unit.class │ │ └── jars │ │ ├── org-csystem-math.jar │ │ └── org-csystem-util.jar └── Sample │ ├── Sample.iml │ ├── libs │ ├── org-csystem-math.jar │ └── org-csystem-util.jar │ ├── out │ └── production │ │ └── Sample │ │ └── org │ │ └── csystem │ │ ├── app │ │ ├── App.class │ │ └── GetReverseTest.class │ │ └── samples │ │ └── recurison │ │ ├── RecursionUtil.class │ │ └── Util.class │ └── src │ └── org │ └── csystem │ ├── app │ └── App.java │ └── samples │ └── recurison │ ├── RecursionUtil.java │ └── Util.java ├── JavaAppLesson004 ├── JavaEE004.md ├── Libraries │ └── IntelliJ │ │ ├── Libraries │ │ ├── Libraries.iml │ │ ├── MathLib │ │ │ ├── MathLib.iml │ │ │ └── src │ │ │ │ └── org │ │ │ │ └── csystem │ │ │ │ └── math │ │ │ │ ├── Complex.java │ │ │ │ ├── Rational.java │ │ │ │ ├── RationalException.java │ │ │ │ ├── RationalExceptionStatus.java │ │ │ │ └── geometry │ │ │ │ ├── AnalyticalCircle.java │ │ │ │ ├── Circle.java │ │ │ │ ├── Point.java │ │ │ │ └── PointF.java │ │ ├── UtilLib │ │ │ ├── UtilLib.iml │ │ │ └── src │ │ │ │ └── org │ │ │ │ └── csystem │ │ │ │ └── util │ │ │ │ ├── ArrayUtil.java │ │ │ │ ├── CommandLineUtil.java │ │ │ │ ├── Console.java │ │ │ │ ├── ConsoleUtil.java │ │ │ │ ├── IntValue.java │ │ │ │ ├── NumberUtil.java │ │ │ │ ├── Pair.java │ │ │ │ ├── StringSplitOptions.java │ │ │ │ ├── StringUtil.java │ │ │ │ ├── Triple.java │ │ │ │ └── Unit.java │ │ └── out │ │ │ └── production │ │ │ ├── MathLib │ │ │ └── org │ │ │ │ └── csystem │ │ │ │ └── math │ │ │ │ ├── Complex.class │ │ │ │ ├── Rational.class │ │ │ │ ├── RationalException.class │ │ │ │ ├── RationalExceptionStatus.class │ │ │ │ └── geometry │ │ │ │ ├── AnalyticalCircle.class │ │ │ │ ├── Circle.class │ │ │ │ ├── Point.class │ │ │ │ └── PointF.class │ │ │ └── UtilLib │ │ │ └── org │ │ │ └── csystem │ │ │ └── util │ │ │ ├── ArrayUtil.class │ │ │ ├── CommandLineUtil.class │ │ │ ├── Console$Error.class │ │ │ ├── Console.class │ │ │ ├── ConsoleUtil.class │ │ │ ├── IntValue.class │ │ │ ├── NumberUtil.class │ │ │ ├── Pair.class │ │ │ ├── StringSplitOptions.class │ │ │ ├── StringUtil.class │ │ │ ├── Triple.class │ │ │ └── Unit.class │ │ └── jars │ │ ├── org-csystem-math.jar │ │ └── org-csystem-util.jar └── Sample │ ├── Sample.iml │ ├── libs │ ├── org-csystem-math.jar │ └── org-csystem-util.jar │ ├── out │ └── production │ │ └── Sample │ │ └── org │ │ └── csystem │ │ ├── app │ │ └── App.class │ │ └── samples │ │ └── recurison │ │ ├── RecursionUtil.class │ │ └── Util.class │ └── src │ └── org │ └── csystem │ ├── app │ └── App.java │ └── samples │ └── recurison │ ├── RecursionUtil.java │ └── Util.java ├── JavaAppLesson005 ├── JavaEE005.md └── org │ └── csystem │ ├── app │ └── App.java │ ├── samples │ └── recurison │ │ ├── RecursionUtil.java │ │ └── Util.java │ └── util │ └── BitwiseUtil.java ├── JavaAppLesson006 ├── JavaEE006.md └── org │ └── csystem │ ├── app │ └── App.java │ ├── samples │ └── recurison │ │ ├── RecursionUtil.java │ │ └── Util.java │ └── util │ └── BitwiseUtil.java ├── JavaAppLesson007 └── JavaEE007.md ├── JavaAppLesson008 └── JavaEE008.md ├── JavaAppLesson009 └── JavaEE009.md └── README.md /JavaAppLesson001/org/csystem/app/App.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | StringUtil sınıfının getRandomText metodu 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.app; 5 | 6 | import org.csystem.util.Console; 7 | import org.csystem.util.StringUtil; 8 | 9 | import java.util.Random; 10 | 11 | class App { 12 | public static void main(String [] args) 13 | { 14 | int n = Console.readInt("Bir sayı giriniz:"); 15 | Random r = new Random(); 16 | 17 | Console.writeLine(StringUtil.getRandomTextTR(r, n)); 18 | Console.writeLine(StringUtil.getRandomTextEN(r, n)); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/centrallimittheorem/CentralLimitTheoremSimulation.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | CentralLimitTheoremSimulation sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | 5 | package org.csystem.app.samples.centrallimittheorem; 6 | 7 | import org.csystem.util.ArrayUtil; 8 | 9 | import java.util.Random; 10 | 11 | public class CentralLimitTheoremSimulation { 12 | private final int m_max; 13 | private final int m_sampleCount; 14 | private final int m_count; 15 | private final int m_divisor; 16 | private final int [] m_counts; 17 | private final Random m_random; 18 | 19 | private double getSamplesAverage() 20 | { 21 | double sum = 0; 22 | 23 | for (int i = 0; i < m_sampleCount; ++i) 24 | sum += m_random.nextInt(m_max + 1); 25 | 26 | return sum / m_sampleCount; 27 | } 28 | 29 | private void start() 30 | { 31 | for (int i = 0; i < m_count; ++i) { 32 | double avg = getSamplesAverage(); 33 | 34 | ++m_counts[(int)avg / m_divisor]; 35 | } 36 | } 37 | 38 | public CentralLimitTheoremSimulation(int max, int sampleCount, int count, int n) 39 | { 40 | //... 41 | m_max = max; 42 | m_sampleCount = sampleCount; 43 | m_count = count; 44 | m_counts = new int[n]; 45 | m_random = new Random(); 46 | m_divisor = m_max / m_counts.length; 47 | } 48 | 49 | public void run(int n, char ch) 50 | { 51 | start(); 52 | ArrayUtil.display(m_counts); 53 | ArrayUtil.drawHistogram(m_counts, n, ch); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/centrallimittheorem/CentralLimitTheoremSimulationApp.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | CentralLimitTheoremSimulationApp sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.app.samples.centrallimittheorem; 5 | 6 | public class CentralLimitTheoremSimulationApp { 7 | public static void run() 8 | { 9 | CentralLimitTheoremSimulation clt = new CentralLimitTheoremSimulation(10000, 5, 100_000_000, 10); 10 | 11 | clt.run(20, 'X'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/commandpromptapp/CommandPrompt.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.commandpromptapp; 2 | 3 | import org.csystem.util.ArrayUtil; 4 | import org.csystem.util.StringUtil; 5 | 6 | import java.util.Scanner; 7 | 8 | public class CommandPrompt { 9 | private String m_prompt; 10 | private static final String [] MS_COMMANDS = {"length", "reverse", "upper", "lower", "prompt", "clear", "quit"}; 11 | 12 | private void doWorkForCommand(int i, String [] cmds) 13 | { 14 | switch (MS_COMMANDS[i]) { 15 | case "length": 16 | lengthProc(cmds); 17 | break; 18 | case "reverse": 19 | reverseProc(cmds); 20 | break; 21 | case "upper": 22 | upperProc(cmds); 23 | break; 24 | case "lower": 25 | lowerProc(cmds); 26 | break; 27 | case "prompt": 28 | promptProc(cmds); 29 | break; 30 | case "clear": 31 | clearProc(cmds); 32 | break; 33 | case "quit": 34 | quitProc(cmds); 35 | break; 36 | } 37 | } 38 | 39 | private void doWorkForCommands(String [] cmds) 40 | { 41 | if (cmds[0].length() < 3) { 42 | System.out.println("Komut en az 3 karakterli olmalıdır"); 43 | return; 44 | } 45 | int i; 46 | 47 | for (i = 0; i < MS_COMMANDS.length; ++i) 48 | if (MS_COMMANDS[i].startsWith(cmds[0])) { 49 | doWorkForCommand(i, cmds); 50 | break; 51 | } 52 | 53 | if (i == MS_COMMANDS.length) 54 | System.out.println("Geçersiz komut"); 55 | } 56 | 57 | private void lengthProc(String [] cmds) 58 | { 59 | String s = ArrayUtil.join(cmds, 1, ' '); 60 | 61 | System.out.println(s.length()); 62 | } 63 | 64 | private void reverseProc(String [] cmds) 65 | { 66 | String s = ArrayUtil.join(cmds, 1, ' '); 67 | 68 | System.out.println(StringUtil.reverse(s)); 69 | } 70 | 71 | private void upperProc(String [] cmds) 72 | { 73 | String s = ArrayUtil.join(cmds, 1, ' '); 74 | 75 | System.out.println(s.toUpperCase()); 76 | } 77 | 78 | private void lowerProc(String [] cmds) 79 | { 80 | String s = ArrayUtil.join(cmds, 1, ' '); 81 | 82 | System.out.println(s.toLowerCase()); 83 | } 84 | 85 | private void promptProc(String [] cmds) 86 | { 87 | String s = ArrayUtil.join(cmds, 1, ' '); 88 | 89 | m_prompt = s; 90 | } 91 | 92 | private void clearProc(String [] cmds) 93 | { 94 | if (cmds.length > 1) { 95 | System.out.println("clear komutu tek başına kullanılmalıdır"); 96 | return; 97 | } 98 | 99 | for (int i = 0; i < 30; ++i) 100 | System.out.println(); 101 | } 102 | 103 | private void quitProc(String [] cmds) 104 | { 105 | if (cmds.length > 1) { 106 | System.out.println("quit komutu tek başına yazılmalıdır"); 107 | return; 108 | } 109 | System.out.println("Copyleft @ C ve Sistem Programcıları Derneği"); 110 | System.out.println("Tekrar yapıyor musunuz?"); 111 | System.exit(0); 112 | } 113 | 114 | public CommandPrompt(String prompt) 115 | { 116 | m_prompt = prompt; 117 | } 118 | 119 | public void run() 120 | { 121 | Scanner kb = new Scanner(System.in); 122 | 123 | for (;;) { 124 | System.out.print(m_prompt + ">"); 125 | String cmdStr = kb.nextLine(); 126 | 127 | String [] cmds = cmdStr.split("[ \t]+"); 128 | 129 | doWorkForCommands(cmds); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/commandpromptapp/CommandPromptApp.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | CommandPromptApp sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.app.samples.commandpromptapp; 5 | 6 | public class CommandPromptApp { 7 | private CommandPromptApp() {} 8 | public static void run() 9 | { 10 | CommandPrompt cp = new CommandPrompt("CSD"); 11 | 12 | cp.run(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/companyapp/CompanyApp.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public class CompanyApp { 4 | public static void run() 5 | { 6 | HumanResources humanResources = new HumanResources(); 7 | Worker worker = new Worker("12345678912", "Ali", "mecidiyeköy", 60.5, 8); 8 | 9 | humanResources.payInsurance(worker); 10 | 11 | Manager manager = new Manager("12345676542", "Veli", "Fatih", "yazılım", 200000); 12 | 13 | humanResources.payInsurance(manager); 14 | 15 | ProjectWorker projectWorker = new ProjectWorker("12356789348", "Selami", "şişli", 60.5, 8, "Okul otomasyonu"); 16 | 17 | humanResources.payInsurance(projectWorker); 18 | 19 | SalesManager salesManager = new SalesManager("12345676548", "Ayşe", "Beylikdüzü", "yazılım", 10000, 3000); 20 | 21 | humanResources.payInsurance(salesManager); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/companyapp/Employee.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public abstract class Employee { 4 | private String m_citizenId; 5 | private String m_name; 6 | private String m_address; 7 | //... 8 | 9 | protected Employee(String citizenId, String name, String address) 10 | { 11 | m_citizenId = citizenId; 12 | m_name = name; 13 | m_address = address; 14 | } 15 | 16 | public String getCitizenId() 17 | { 18 | return m_citizenId; 19 | } 20 | 21 | public void setCitizenId(String citizenId) 22 | { 23 | m_citizenId = citizenId; 24 | } 25 | 26 | public String getName() 27 | { 28 | return m_name; 29 | } 30 | 31 | public void setName(String name) 32 | { 33 | m_name = name; 34 | } 35 | 36 | public String getAddress() 37 | { 38 | return m_address; 39 | } 40 | 41 | public void setAddress(String address) 42 | { 43 | m_address = address; 44 | } 45 | 46 | public abstract double calculatePayment(); 47 | } 48 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/companyapp/HumanResources.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public class HumanResources { 4 | //... 5 | public void payInsurance(Employee employee) 6 | { 7 | System.out.printf("Citizen Id:%s%n", employee.getCitizenId()); 8 | System.out.printf("Name Id:%s%n", employee.getName()); 9 | System.out.printf("Payment:%f%n", employee.calculatePayment()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/companyapp/Manager.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public class Manager extends Employee { 4 | private String m_department; 5 | private double m_salary; 6 | 7 | public Manager(String citizenId, String name, String address, String department, double salary) 8 | { 9 | super(citizenId, name, address); 10 | m_department = department; 11 | m_salary = salary; 12 | } 13 | 14 | public String getDepartment() 15 | { 16 | return m_department; 17 | } 18 | 19 | public void setDepartment(String department) 20 | { 21 | m_department = department; 22 | } 23 | 24 | public double getSalary() 25 | { 26 | return m_salary; 27 | } 28 | 29 | public void setSalary(double salary) 30 | { 31 | m_salary = salary; 32 | } 33 | public double calculatePayment() 34 | { 35 | return m_salary * m_salary * 0.5; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/companyapp/ProjectWorker.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public class ProjectWorker extends Worker { 4 | private String m_project; 5 | 6 | public ProjectWorker(String citizenId, String name, String address, double feePerHour, int hourPerDay, String project) 7 | { 8 | super(citizenId, name, address, feePerHour, hourPerDay); 9 | m_project = project; 10 | } 11 | 12 | public String getProject() 13 | { 14 | return m_project; 15 | } 16 | 17 | public void setProject(String project) 18 | { 19 | m_project = project; 20 | } 21 | 22 | public double calculatePayment() 23 | { 24 | return super.calculatePayment() + 1.5; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/companyapp/SalesManager.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public class SalesManager extends Manager { 4 | private double m_extra; 5 | 6 | public SalesManager(String citizenId, String name, String address, String department, double salary, double extra) 7 | { 8 | super(citizenId, name, address, department, salary); 9 | m_extra = extra; 10 | } 11 | 12 | public double getExtra() 13 | { 14 | return m_extra; 15 | } 16 | 17 | public void setExtra(double extra) 18 | { 19 | m_extra = extra; 20 | } 21 | 22 | public double calculatePayment() 23 | { 24 | return super.calculatePayment() + m_extra; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/companyapp/Worker.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public class Worker extends Employee { 4 | private double m_feePerHour; 5 | private int m_hourPerDay; 6 | 7 | public Worker(String citizenId, String name, String address, double feePerHour, int hourPerDay) 8 | { 9 | super(citizenId, name, address); 10 | //... 11 | m_feePerHour = feePerHour; 12 | m_hourPerDay = hourPerDay; 13 | } 14 | 15 | public double getFeePerHour() 16 | { 17 | return m_feePerHour; 18 | } 19 | 20 | public void setFeePerHour(double feePerHour) 21 | { 22 | m_feePerHour = feePerHour; 23 | } 24 | 25 | public int getHourPerDay() 26 | { 27 | return m_hourPerDay; 28 | } 29 | 30 | public void setHourPerDay(int hourPerDay) 31 | { 32 | m_hourPerDay = hourPerDay; 33 | } 34 | 35 | public double calculatePayment() 36 | { 37 | return m_feePerHour * m_hourPerDay * 30; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/dateapp/DateTestApp.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Sınıf Çalışması: Parametresi ile aldığı gün, ay ve yıl bilgisine ilişkin tarihin aşağıdaki açıklamalara 3 | göre yılın hangi günü olduğu bilgisini döndüren getDayOfWeek isimli metodu yazınız. 4 | Açıklamalar: 5 | - Metot geçersiz bir tarih için -1 değerine dönecektir 6 | - Metot 1900 yılından önceki tarihler için geçersiz tarih kabul edecektir. 7 | - Gün bilgisi "1.1.1900 ile verilen tarih arasındaki geçen gün sayısının 7 ile bölümünden elde 8 | edilen kalan" ile bulunabilir. Kalan değeri 0 için Pazar, 1 için Pazartesi, ..., 6 için Cumartesi 9 | olacak şekilde düşünülmelidir 10 | - Tarih bilgisi gün bilgisi ile birlikte yazdırılacaktır. Yazdırma işlemi için displayDateTR ve 11 | displayDateEN isimli Türkçe ve İngilizce olarak ekrana basan metotlar yazılarak yapılabilir 12 | - Tarih hafta sonuna geliyorsa "Bugün kurs var. Tekrar yaptınız mı?" mesajı hafta içi bir güne geliyorsa 13 | "Tekrar yapmayı unutmayınız" biçiminde mesaj yazılacaktır 14 | - İleride daha iyileri yazılacak 15 | ----------------------------------------------------------------------------------------------------------------------*/ 16 | 17 | package org.csystem.app.samples.dateapp; 18 | 19 | import org.csystem.util.datetime.Date; 20 | 21 | public class DateTestApp { 22 | private DateTestApp() {} 23 | 24 | public static void run() 25 | { 26 | java.util.Scanner kb = new java.util.Scanner(System.in); 27 | 28 | for (;;) { 29 | System.out.print("Gün?"); 30 | int day = Integer.parseInt(kb.nextLine()); 31 | 32 | if (day == 0) 33 | break; 34 | 35 | System.out.print("Ay?"); 36 | int mon = Integer.parseInt(kb.nextLine()); 37 | 38 | System.out.print("Yıl?"); 39 | int year = Integer.parseInt(kb.nextLine()); 40 | 41 | Date date = new Date(day, mon, year); 42 | 43 | System.out.println(date.toLongDateStringTR()); 44 | System.out.println(date.toLongDateStringEN()); 45 | 46 | if (date.isWeekend()) 47 | System.out.println("Bugün kurs var tekrar yaptnız mı?"); 48 | else 49 | System.out.println("Hafta sonu kurs var tekrar yapmayı unutmayınız!!!"); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/dateapp/DateUtil.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.dateapp; 2 | 3 | public class DateUtil { 4 | private static int [] ms_daysOfMonths = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 5 | private static String [] ms_weekDaysTR = {"Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"}; 6 | private static String [] ms_weekDaysEN = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; 7 | private static String [] ms_monthsTR = {"", "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", 8 | "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"}; 9 | private static String [] ms_monthsEN = {"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; 10 | 11 | private DateUtil() {} 12 | 13 | public static void displayDateTR(int day, int mon, int year) 14 | { 15 | int dayOfWeek = getDayOfWeek(day, mon, year); 16 | 17 | if (dayOfWeek == -1) { 18 | System.out.println("Geçersiz tarih"); 19 | return; 20 | } 21 | 22 | System.out.printf("%02d %s %04d %s%n", day, ms_monthsTR[mon], year, ms_weekDaysTR[dayOfWeek]); 23 | 24 | if (isWeekend(day, mon, year)) 25 | System.out.println("Bugün kurs var. Tekrar yaptınız mı?"); 26 | else 27 | System.out.println("Tekrar yapmayı unutmayınız!!!"); 28 | } 29 | 30 | public static void displayDateEN(int day, int mon, int year) 31 | { 32 | int dayOfWeek = getDayOfWeek(day, mon, year); 33 | 34 | if (dayOfWeek == -1) { 35 | System.out.println("Geçersiz tarih"); 36 | return; 37 | } 38 | 39 | System.out.printf("%02d %s %04d %s%n", day, ms_monthsEN[mon], year, ms_weekDaysEN[dayOfWeek]); 40 | } 41 | 42 | public static boolean isWeekend(int day, int mon, int year) 43 | { 44 | int dayOfWeek = getDayOfWeek(day, mon, year); 45 | 46 | //... 47 | 48 | return dayOfWeek == 0 || dayOfWeek == 6; 49 | } 50 | 51 | public static boolean isWeekday(int day, int mon, int year) 52 | { 53 | return !isWeekend(day, mon, year); 54 | } 55 | 56 | public static int getDayOfWeek(int day, int mon, int year) 57 | { 58 | int dayOfYear = getDayOfYear(day, mon, year); 59 | 60 | if (dayOfYear == -1 || year < 1900) 61 | return -1; 62 | 63 | int totalDays = dayOfYear; 64 | 65 | for (int y = 1900; y < year; ++y) 66 | totalDays += isLeapYear(y) ? 366 : 365; 67 | 68 | return totalDays % 7; 69 | } 70 | 71 | public static int getDayOfYear(int day, int mon, int year) 72 | { 73 | if (!isValidDate(day, mon, year)) 74 | return -1; 75 | 76 | int dayOfYear = day; 77 | 78 | for (int m = mon - 1; m >= 1; --m) 79 | dayOfYear += ms_daysOfMonths[m]; 80 | 81 | if (mon > 2 && isLeapYear(year)) 82 | ++dayOfYear; 83 | 84 | return dayOfYear; 85 | } 86 | 87 | public static boolean isValidDate(int day, int mon, int year) 88 | { 89 | if (day < 1 || day > 31 || mon < 1 || mon > 12) 90 | return false; 91 | 92 | int days = mon == 2 && isLeapYear(year) ? 29 : ms_daysOfMonths[mon]; 93 | 94 | return day <= days; 95 | } 96 | 97 | public static boolean isLeapYear(int year) 98 | { 99 | return year % 4 == 0 && year % 100 != 0 || year % 400 == 0; 100 | } 101 | } -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/dateapp/DateUtilTestApp.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Sınıf Çalışması: Parametresi ile aldığı gün, ay ve yıl bilgisine ilişkin tarihin aşağıdaki açıklamalara 3 | göre yılın hangi günü olduğu bilgisini döndüren getDayOfWeek isimli metodu yazınız. 4 | Açıklamalar: 5 | - Metot geçersiz bir tarih için -1 değerine dönecektir 6 | - Metot 1900 yılından önceki tarihler için geçersiz tarih kabul edecektir. 7 | - Gün bilgisi "1.1.1900 ile verilen tarih arasındaki geçen gün sayısının 7 ile bölümünden elde 8 | edilen kalan" ile bulunabilir. Kalan değeri 0 için Pazar, 1 için Pazartesi, ..., 6 için Cumartesi 9 | olacak şekilde düşünülmelidir 10 | - Tarih bilgisi gün bilgisi ile birlikte yazdırılacaktır. Yazdırma işlemi için displayDateTR ve 11 | displayDateEN isimli Türkçe ve İngilizce olarak ekrana basan metotlar yazılarak yapılabilir 12 | - Tarih hafta sonuna geliyorsa "Bugün kurs var. Tekrar yaptınız mı?" mesajı hafta içi bir güne geliyorsa 13 | "Tekrar yapmayı unutmayınız" biçiminde mesaj yazılacaktır 14 | - İleride daha iyileri yazılacak 15 | ----------------------------------------------------------------------------------------------------------------------*/ 16 | 17 | package org.csystem.app.samples.dateapp; 18 | 19 | public class DateUtilTestApp { 20 | private DateUtilTestApp() {} 21 | 22 | public static void run() 23 | { 24 | java.util.Scanner kb = new java.util.Scanner(System.in); 25 | 26 | for (;;) { 27 | System.out.print("Gün?"); 28 | int day = Integer.parseInt(kb.nextLine()); 29 | 30 | if (day == 0) 31 | break; 32 | 33 | System.out.print("Ay?"); 34 | int mon = Integer.parseInt(kb.nextLine()); 35 | 36 | System.out.print("Yıl?"); 37 | int year = Integer.parseInt(kb.nextLine()); 38 | 39 | DateUtil.displayDateTR(day, mon, year); 40 | DateUtil.displayDateEN(day, mon, year); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/examsimulationapp/ExamSimulation.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.examsimulationapp; 2 | 3 | import org.csystem.util.ArrayUtil; 4 | import org.csystem.util.ConsoleUtil; 5 | 6 | import java.util.Random; 7 | import java.util.Scanner; 8 | 9 | public class ExamSimulation { 10 | private final String m_lectureName; 11 | private int [][] m_grades; 12 | private double [] m_averages; 13 | private double average; 14 | 15 | public void fillGrades(Scanner kb) 16 | { 17 | Random r = new Random(); 18 | 19 | for (int i = 0; i < m_grades.length; ++i) { 20 | System.out.printf("%d. şube öğrenci sayısını giriniz:", i + 1); 21 | m_grades[i] = ArrayUtil.getRandomArray(r, Integer.parseInt(kb.nextLine()), 0, 101); 22 | } 23 | } 24 | 25 | public void createGradesInfo() 26 | { 27 | Scanner kb = new Scanner(System.in); 28 | System.out.printf("'%s' sınavı şube sayısını giriniz:", m_lectureName); 29 | int n = Integer.parseInt(kb.nextLine()); 30 | 31 | m_grades = new int[n][]; 32 | m_averages = new double[n]; 33 | 34 | fillGrades(kb); 35 | } 36 | 37 | public void calculateAverages() 38 | { 39 | int totalGrade = 0; 40 | int numberOfStudents = 0; 41 | 42 | for (int i = 0; i < m_grades.length; ++i) { 43 | int sumOfGrades = ArrayUtil.sum(m_grades[i]); 44 | 45 | totalGrade += sumOfGrades; 46 | numberOfStudents += m_grades[i].length; 47 | m_averages[i] = (double)sumOfGrades / m_grades[i].length; 48 | } 49 | 50 | average = (double)totalGrade / numberOfStudents; 51 | } 52 | 53 | public void displayHeader() 54 | { 55 | String fmt = String.format("%n%s DERSİ SINAV RAPORU:%n", m_lectureName); 56 | System.out.printf(fmt, m_lectureName); 57 | ConsoleUtil.putCharsLine(fmt.length(), '-'); 58 | } 59 | 60 | public void displayGrades() 61 | { 62 | System.out.println("Şube Notları:"); 63 | ConsoleUtil.putCharsLine(13, '-'); 64 | 65 | for (int i = 0; i < m_grades.length; ++i) { 66 | System.out.printf("%d. şube notlar:%n", i + 1); 67 | ArrayUtil.display(2, m_grades[i]); 68 | } 69 | } 70 | 71 | public void displayAverages() 72 | { 73 | System.out.println("Ortalamalar:"); 74 | ConsoleUtil.putCharsLine(13, '-'); 75 | for (int i = 0; i < m_averages.length; ++i) 76 | System.out.printf("%d. şube ortalaması:%f%n", i + 1, m_averages[i]); 77 | 78 | System.out.printf("Okul ortalaması:%f%n", average); 79 | } 80 | 81 | public ExamSimulation(String name) 82 | { 83 | m_lectureName = name; 84 | } 85 | 86 | public void displayReport() 87 | { 88 | displayHeader(); 89 | displayGrades(); 90 | displayAverages(); 91 | System.out.println("///////////////////////////"); 92 | } 93 | 94 | public void run() 95 | { 96 | createGradesInfo(); 97 | calculateAverages(); 98 | } 99 | 100 | // 101 | } 102 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/examsimulationapp/ExamSimulationApp.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.examsimulationapp; 2 | 3 | public class ExamSimulationApp { 4 | private ExamSimulationApp() {} 5 | public static void run() 6 | { 7 | ExamSimulation [] examSimulations = {new ExamSimulation("Matematik"), new ExamSimulation("Kimya")}; 8 | 9 | for (int i = 0; i < examSimulations.length; ++i) 10 | examSimulations[i].run(); 11 | 12 | for (int i = 0; i < examSimulations.length; ++i) 13 | examSimulations[i].displayReport(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/lottaryapp/Lottary.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.lottaryapp; 2 | 3 | import java.util.Random; 4 | 5 | public class Lottary { 6 | private Random m_random; 7 | 8 | private static int [] getNumbers(boolean [] flags) 9 | { 10 | int [] numbers = new int[6]; 11 | 12 | int index = 0; 13 | 14 | for (int i = 1; i < 50; ++i) 15 | if (flags[i]) 16 | numbers[index++] = i; 17 | 18 | return numbers; 19 | } 20 | 21 | private boolean [] getFlags() 22 | { 23 | boolean [] flags = new boolean[50]; 24 | int val; 25 | 26 | for (int i = 0; i < 6; ++i) { 27 | for (;;) { 28 | val = m_random.nextInt(49) + 1; 29 | if (!flags[val]) 30 | break; 31 | } 32 | flags[val] = true; 33 | } 34 | 35 | return flags; 36 | } 37 | 38 | public Lottary() 39 | { 40 | this(new Random()); 41 | } 42 | 43 | public Lottary(Random r) 44 | { 45 | m_random = r; 46 | } 47 | 48 | public int [] getNumbers() 49 | { 50 | return getNumbers(getFlags()); 51 | } 52 | 53 | public int [][] getNumbers(int n) 54 | { 55 | int [][] a = new int[n][]; 56 | 57 | for (int i = 0; i < n; ++i) 58 | a[i] = getNumbers(); 59 | 60 | return a; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/lottaryapp/LottaryTest.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.lottaryapp; 2 | 3 | import org.csystem.util.ArrayUtil; 4 | 5 | import java.util.Scanner; 6 | 7 | public class LottaryTest { 8 | private LottaryTest() {} 9 | public static void run() 10 | { 11 | Scanner kb = new Scanner(System.in); 12 | System.out.print("Kaç kupon oynamak istiyorsunuz?"); 13 | int n = Integer.parseInt(kb.nextLine()); 14 | 15 | Lottary lottary = new Lottary(); 16 | 17 | ArrayUtil.display(2, lottary.getNumbers(n)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/parserapp/CharArraySource.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.parserapp; 2 | 3 | public class CharArraySource implements ISource { 4 | private final char[] m_chars; 5 | private int m_index; 6 | 7 | public CharArraySource(String string) 8 | { 9 | m_chars = string.toCharArray(); 10 | } 11 | 12 | public int getChar() 13 | { 14 | return m_index == m_chars.length ? -1 : m_chars[m_index++]; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/parserapp/ISource.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.parserapp; 2 | 3 | public interface ISource { 4 | int getChar(); 5 | } 6 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/parserapp/Parser.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.parserapp; 2 | 3 | public class Parser { 4 | private ISource m_source; 5 | 6 | public Parser(ISource source) 7 | { 8 | //... 9 | m_source = source; 10 | } 11 | 12 | public ISource getSource() 13 | { 14 | return m_source; 15 | } 16 | 17 | public void setSource(ISource source) 18 | { 19 | m_source = source; 20 | } 21 | 22 | public void doParse() 23 | { 24 | int count = 0; 25 | int ch; 26 | 27 | while ((ch = m_source.getChar()) != -1) 28 | if (Character.isLetter((char)ch)) 29 | ++count; 30 | 31 | System.out.printf("Count:%d%n", count); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/parserapp/ParserApp.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.parserapp; 2 | 3 | public class ParserApp { 4 | public static void run() 5 | { 6 | StringSource stringSource = new StringSource("bugün hava 25 derece"); 7 | Parser parser = new Parser(stringSource); 8 | 9 | parser.doParse(); 10 | 11 | CharArraySource charArraySource = new CharArraySource("Ali Serçe"); 12 | 13 | parser.setSource(charArraySource); 14 | 15 | parser.doParse(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/parserapp/StringSource.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.parserapp; 2 | 3 | public class StringSource implements ISource { 4 | private final String m_str; 5 | private int m_index; 6 | 7 | public StringSource(String str) 8 | { 9 | m_str = str; 10 | } 11 | 12 | public int getChar() 13 | { 14 | return m_index == m_str.length() ? -1 : m_str.charAt(m_index++); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/randomobjectsgeneratorapp/RandomObjectsGenerator.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.randomobjectsgeneratorapp; 2 | 3 | import org.csystem.util.IntValue; 4 | import org.csystem.util.StringUtil; 5 | import org.csystem.util.datetime.Date; 6 | import org.csystem.util.datetime.Time; 7 | 8 | import java.util.Random; 9 | 10 | public class RandomObjectsGenerator { 11 | private Random m_random; 12 | private Object [] m_objects; 13 | 14 | public Object getRandomObject() 15 | { 16 | Object result = IntValue.of(m_random.nextInt(255) - 128); 17 | 18 | switch (m_random.nextInt(6)) { 19 | case 0: 20 | result = Date.randomDate(m_random); 21 | break; 22 | case 1: 23 | result = StringUtil.getRandomTextEN(m_random, m_random.nextInt(10)); 24 | break; 25 | case 2: 26 | result = Time.randomLongTime(m_random); 27 | break; 28 | case 3: 29 | result = m_random.nextInt(101); //auto-boxing 30 | break; 31 | case 4: 32 | result = m_random.nextDouble(); //auto-boxing 33 | break; 34 | } 35 | 36 | return result; 37 | } 38 | 39 | public RandomObjectsGenerator(int count) 40 | { 41 | this(new Random(), count); 42 | } 43 | 44 | public RandomObjectsGenerator(Random random, int count) 45 | { 46 | m_random = random; 47 | m_objects = new Object[count]; 48 | } 49 | 50 | public Object[] getObjects() 51 | { 52 | return m_objects; 53 | } 54 | 55 | public void generate() 56 | { 57 | for (int i = 0; i < m_objects.length; ++i) 58 | m_objects[i] = getRandomObject(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/randomobjectsgeneratorapp/RandomObjectsGeneratorApp.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.randomobjectsgeneratorapp; 2 | 3 | import org.csystem.util.IntValue; 4 | import org.csystem.util.datetime.Date; 5 | import org.csystem.util.datetime.Time; 6 | 7 | import java.util.Random; 8 | import java.util.Scanner; 9 | 10 | public class RandomObjectsGeneratorApp { 11 | private static void dateProc(Date date) 12 | { 13 | System.out.println("Date:"); 14 | System.out.println(date.toLongDateStringEN()); 15 | System.out.println(date.toLongDateStringTR()); 16 | 17 | } 18 | private static void timeProc(Time time) 19 | { 20 | System.out.println("Time:"); 21 | System.out.println(time.toLongTimeString()); 22 | } 23 | 24 | private static void intValueProc(IntValue intValue) 25 | { 26 | System.out.println("IntValue:"); 27 | System.out.println(intValue.getVal()); 28 | System.out.println(intValue.inc(5).getVal()); 29 | } 30 | 31 | private static void stringProc(String str) 32 | { 33 | System.out.println("String:"); 34 | System.out.println(str); 35 | System.out.println(str.toUpperCase()); 36 | } 37 | 38 | private static void integerProc(int val) 39 | { 40 | System.out.println("Integer:"); 41 | System.out.printf("%d * %d = %d%n", val, val, val * val); 42 | } 43 | 44 | private static void doubleProc(double val) 45 | { 46 | System.out.println("Double:"); 47 | 48 | System.out.println(val); 49 | } 50 | 51 | private static void doWork(RandomObjectsGenerator randomObjectsGenerator) 52 | { 53 | randomObjectsGenerator.generate(); 54 | for (Object object : randomObjectsGenerator.getObjects()) { 55 | if (object instanceof Date) 56 | dateProc((Date)object); 57 | else if (object instanceof Time) 58 | timeProc((Time)object); 59 | else if (object instanceof IntValue) 60 | intValueProc((IntValue)object); 61 | else if (object instanceof String) 62 | stringProc((String)object); 63 | else if (object instanceof Integer) 64 | integerProc((int)object); 65 | else 66 | doubleProc((double)object); 67 | } 68 | } 69 | 70 | public static void run() 71 | { 72 | Scanner kb = new Scanner(System.in); 73 | System.out.print("Dizinin eleman sayısını giriniz"); 74 | int count = Integer.parseInt(kb.nextLine()); 75 | Random r = new Random(); 76 | RandomObjectsGenerator randomObjectsGenerator = new RandomObjectsGenerator(r, count); 77 | 78 | doWork(randomObjectsGenerator); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/sentenceterminalapp/SentenceTerminal.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Sınıf Çalışması: Aşağıdaki gibi çalışan bir komut yorumlayıcı program yazınız. 3 | Açıklamalar: 4 | - Program bir komut yorumlayıcı olarak aşağıdaki komutlar kabul edecektir. 5 | - stat 6 | - quit 7 | - stat komutundan sonra bir cümle gelmelidir. Cümlenn isogram, değilse pangram değilse hiçbiri olarak 8 | sonucu elde edilecektir 9 | 10 | > stat abcdefghijklm nopqrstuwxvyz 11 | isogram 12 | > stat abcdefghijklmno ......pqrsatuwxvyz 13 | pangram 14 | > stat abcdefghijklmnopqrtuw ....xvyz 15 | nothing 16 | - Sadece İngilizce alfabedeki karakterler gözönüne alınacaktır
 17 | ----------------------------------------------------------------------------------------------------------------------*/ 18 | package org.csystem.app.samples.sentenceterminalapp; 19 | 20 | import org.csystem.util.ArrayUtil; 21 | 22 | import java.util.Scanner; 23 | 24 | public class SentenceTerminal { 25 | private final String m_prompt; 26 | private String m_cmd; 27 | 28 | private void fillCounts(int [] counts, String sentence) 29 | { 30 | int len = sentence.length(); 31 | 32 | for (int i = 0; i < len; ++i) { 33 | char c = Character.toLowerCase(sentence.charAt(i)); 34 | if (c < 'a' || c > 'z') 35 | continue; 36 | 37 | ++counts[c - 'a']; 38 | } 39 | } 40 | 41 | private void displayStatus(int [] counts) 42 | { 43 | boolean isPangram = false; 44 | 45 | for (int val : counts) { 46 | if (val == 0) { 47 | System.out.println("Nothing"); 48 | return; 49 | } 50 | if (val > 1) 51 | isPangram = true; 52 | } 53 | 54 | System.out.println(isPangram ? "pangram" : "isogram"); 55 | } 56 | 57 | private void doWorkForSentence(String sentence) 58 | { 59 | int [] counts = new int[26]; 60 | 61 | fillCounts(counts, sentence); 62 | displayStatus(counts); 63 | } 64 | 65 | private void parseCommand() 66 | { 67 | String [] cmdInfo = m_cmd.split("[ \t]+"); 68 | 69 | if (!cmdInfo[0].equals("stat")) { 70 | System.out.println("Invalid command"); 71 | return; 72 | } 73 | 74 | if (cmdInfo.length == 1) { 75 | System.out.println("stat must have a sentence"); 76 | return; 77 | } 78 | 79 | String sentence = ArrayUtil.join(cmdInfo, 1, ""); 80 | 81 | doWorkForSentence(sentence); 82 | } 83 | 84 | public SentenceTerminal(String prompt) 85 | { 86 | m_prompt = prompt; 87 | } 88 | 89 | public void run() 90 | { 91 | Scanner kb = new Scanner(System.in); 92 | 93 | for (;;) { 94 | System.out.print(m_prompt + "> "); 95 | m_cmd = kb.nextLine().trim(); 96 | 97 | if (m_cmd.equals("quit")) 98 | break; 99 | 100 | parseCommand(); 101 | } 102 | 103 | System.out.println("Tekrar yapıyor musunuz?"); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/app/samples/sentenceterminalapp/SentenceTerminalApp.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.sentenceterminalapp; 2 | 3 | public class SentenceTerminalApp { 4 | private SentenceTerminalApp() 5 | {} 6 | 7 | public static void run() 8 | { 9 | SentenceTerminal sentenceTerminal = new SentenceTerminal("CSD"); 10 | 11 | sentenceTerminal.run(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/math/Complex.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Complex sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math; 5 | 6 | import static java.lang.Math.sqrt; 7 | 8 | public class Complex { 9 | private static Complex add(double re1, double im1, double re2, double im2) 10 | { 11 | return new Complex(re1 + re2, im1 + im2); 12 | } 13 | 14 | private static Complex sub(double re1, double im1, double re2, double im2) 15 | { 16 | return add(re1, im1, -re2, -im2); 17 | } 18 | 19 | public double re, im; 20 | 21 | public Complex() 22 | {} 23 | 24 | public Complex(double re) 25 | { 26 | this.re = re; 27 | } 28 | 29 | public Complex(double re, double im) 30 | { 31 | this.re = re; 32 | this.im = im; 33 | } 34 | 35 | public Complex getConjugate() 36 | { 37 | Complex z = new Complex(); 38 | 39 | z.re = re; 40 | z.im = -im; 41 | 42 | return z; 43 | } 44 | 45 | public double getNorm() 46 | { 47 | return sqrt(re * re + im * im); 48 | } 49 | 50 | public static Complex add(double re, double im, Complex z) 51 | { 52 | return add(re, im, z.re, z.im); 53 | } 54 | 55 | public Complex add(Complex z) 56 | { 57 | return add(re, im, z.re, z.im); 58 | } 59 | 60 | public Complex add(double x, double y) 61 | { 62 | return add(re, im, x, y); 63 | } 64 | 65 | public static Complex sub(double re, double im, Complex z) 66 | { 67 | return sub(re, im, z.re, z.im); 68 | } 69 | 70 | public Complex sub(Complex z) 71 | { 72 | return sub(re, im, z.re, z.im); 73 | } 74 | 75 | public Complex sub(double x, double y) 76 | { 77 | return sub(re, im, x, y); 78 | } 79 | 80 | public String toString() 81 | { 82 | return String.format("|%.2f + i * %.2f| = %f", re, im, this.getNorm()); 83 | } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/math/RationalException.java: -------------------------------------------------------------------------------- 1 | package org.csystem.math; 2 | 3 | public class RationalException extends NumberFormatException { 4 | private final RationalExceptionStatus m_rationalExceptionStatus; 5 | 6 | public RationalException(String message, RationalExceptionStatus rationalExceptionStatus) 7 | { 8 | super(message); 9 | m_rationalExceptionStatus = rationalExceptionStatus; 10 | } 11 | 12 | public RationalExceptionStatus getRationalExceptionStatus() 13 | { 14 | return m_rationalExceptionStatus; 15 | } 16 | 17 | public String getMessage() 18 | { 19 | return String.format("Message:%s, Exception Status:%s", super.getMessage(), m_rationalExceptionStatus); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/math/RationalExceptionStatus.java: -------------------------------------------------------------------------------- 1 | package org.csystem.math; 2 | 3 | public enum RationalExceptionStatus { 4 | UNDEFINED, INDEFINITE 5 | } 6 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/math/geometry/AnalyticalCircle.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Analytical sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | public class AnalyticalCircle extends Circle { 7 | private Point m_center; 8 | 9 | public AnalyticalCircle() 10 | { 11 | this(0); 12 | } 13 | 14 | public AnalyticalCircle(double r) 15 | { 16 | this(r, 0, 0); 17 | } 18 | 19 | public AnalyticalCircle(Point center) 20 | { 21 | this(0, center); 22 | } 23 | 24 | public AnalyticalCircle(int x, int y) 25 | { 26 | this(0, x, y); 27 | } 28 | 29 | public AnalyticalCircle(double r, Point center) 30 | { 31 | this(r, center.x, center.y); 32 | } 33 | 34 | public AnalyticalCircle(double r, int x, int y) 35 | { 36 | super(r); 37 | m_center = new Point(x, y); 38 | } 39 | 40 | public int getX() 41 | { 42 | return m_center.x; 43 | } 44 | 45 | public void setX(int x) 46 | { 47 | m_center.x = x; 48 | } 49 | 50 | public int getY() 51 | { 52 | return m_center.y; 53 | } 54 | 55 | public void setY(int y) 56 | { 57 | m_center.y = y; 58 | } 59 | 60 | public void setCenter(Point center) 61 | { 62 | this.setCenter(center.x, center.y); 63 | } 64 | 65 | public void setCenter(int x, int y) 66 | { 67 | this.setX(x); 68 | this.setY(y); 69 | } 70 | 71 | public Point getCenter() 72 | { 73 | return new Point(m_center); 74 | } 75 | 76 | public void offset(int dx, int dy) 77 | { 78 | m_center.offset(dx, dy); 79 | } 80 | 81 | public void offset(int dxy) 82 | { 83 | this.offset(dxy, dxy); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/math/geometry/Circle.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Circle sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | public class Circle { 7 | private double m_r; 8 | 9 | public Circle() 10 | {} 11 | 12 | public Circle(double r) 13 | { 14 | this.setRadius(r); 15 | } 16 | 17 | public double getRadius() 18 | { 19 | return m_r; 20 | } 21 | 22 | public void setRadius(double r) 23 | { 24 | m_r = Math.abs(r); 25 | } 26 | 27 | public double getArea() 28 | { 29 | return Math.PI * m_r * m_r; 30 | } 31 | 32 | public double getCircumference() 33 | { 34 | return 2 * Math.PI * m_r; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/math/geometry/Point.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Point sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | import static java.lang.Math.sqrt; 7 | 8 | public class Point { 9 | public int x, y; 10 | 11 | Point(Point p) 12 | { 13 | this(p.x, p.y); 14 | } 15 | 16 | public Point() 17 | {} 18 | 19 | public Point(int x) 20 | { 21 | this(x, 0); 22 | } 23 | 24 | public Point(int x, int y) 25 | { 26 | this.x = x; 27 | this.y = y; 28 | } 29 | 30 | public double distance(Point p) 31 | { 32 | return this.distance(p.x, p.y); 33 | } 34 | 35 | public double distance(int a, int b) 36 | { 37 | return sqrt((x - a) * (x - a) + (y - b) * (y - b)); 38 | } 39 | 40 | public void offset(int dxy) 41 | { 42 | this.offset(dxy, dxy); 43 | } 44 | 45 | public void offset(int dx, int dy) 46 | { 47 | x += dx; 48 | y += dy; 49 | } 50 | 51 | public String toString() 52 | { 53 | return String.format("(%d, %d)", x, y); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/math/geometry/PointF.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | PointF sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | import static java.lang.Math.sqrt; 7 | 8 | public class PointF { 9 | public float x, y; 10 | 11 | PointF(PointF p) 12 | { 13 | this(p.x, p.y); 14 | } 15 | 16 | public PointF() 17 | {} 18 | 19 | public PointF(float re) 20 | { 21 | this(re, 0); 22 | } 23 | 24 | public PointF(float x, float y) 25 | { 26 | this.x = x; 27 | this.y = y; 28 | } 29 | 30 | public double distance(PointF p) 31 | { 32 | return this.distance(p.x, p.y); 33 | } 34 | 35 | public double distance(float a, float b) 36 | { 37 | return sqrt((x - a) * (x - a) + (y - b) * (y - b)); 38 | } 39 | 40 | public void offset(float dxy) 41 | { 42 | this.offset(dxy, dxy); 43 | } 44 | 45 | public void offset(float dx, float dy) 46 | { 47 | x += dx; 48 | y += dy; 49 | } 50 | 51 | public String toString() 52 | { 53 | return String.format("(%.2f, %.2f)", x, y); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/util/Console.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Console sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | import java.util.Scanner; 7 | 8 | public final class Console { 9 | private static final Scanner KB = new Scanner(System.in); 10 | 11 | private Console() 12 | {} 13 | 14 | //read methods 15 | 16 | public static int readInt() 17 | { 18 | return readInt(""); 19 | } 20 | 21 | public static int readInt(String message) 22 | { 23 | return readInt(message, ""); 24 | } 25 | 26 | public static int readInt(String message, String errMessage) 27 | { 28 | for (;;) { 29 | try { 30 | System.out.print(message); 31 | 32 | return Integer.parseInt(KB.nextLine()); 33 | } 34 | catch (NumberFormatException ex) { 35 | System.out.print(errMessage); 36 | } 37 | } 38 | } 39 | 40 | public static int readIntLine(String message) 41 | { 42 | return readInt(message, ""); 43 | } 44 | 45 | public static int readIntLine(String message, String errMessage) 46 | { 47 | return readInt(message + "\n", errMessage + "\n"); 48 | } 49 | 50 | public static double readDouble() 51 | { 52 | return readDouble(""); 53 | } 54 | 55 | public static double readDouble(String message) 56 | { 57 | return readDouble(message, ""); 58 | } 59 | 60 | public static double readDouble(String message, String errMessage) 61 | { 62 | for (;;) { 63 | try { 64 | System.out.print(message); 65 | 66 | return Double.parseDouble(KB.nextLine()); 67 | } 68 | catch (NumberFormatException ex) { 69 | System.out.print(errMessage); 70 | } 71 | } 72 | } 73 | 74 | public static double readDoubleLine(String message) 75 | { 76 | return readDouble(message, ""); 77 | } 78 | 79 | public static double readDoubleLine(String message, String errMessage) 80 | { 81 | return readDouble(message + "\n", errMessage + "\n"); 82 | } 83 | 84 | public static String readString(String message) 85 | { 86 | System.out.print(message); 87 | 88 | return KB.nextLine(); 89 | } 90 | 91 | public static String readStringLine(String message) 92 | { 93 | return readString(message + "\n"); 94 | } 95 | 96 | 97 | //write methods 98 | 99 | public static void writeChars(int n, char ch) 100 | { 101 | for (int i = 0; i < n; ++i) 102 | System.out.print(ch); 103 | } 104 | 105 | public static void writeCharsLine(int n, char ch) 106 | { 107 | writeChars(n, ch); 108 | System.out.println(); 109 | } 110 | 111 | public static void writeLine() 112 | { 113 | System.out.println(); 114 | } 115 | 116 | public static void writeLine(double val) 117 | { 118 | System.out.println(val); 119 | } 120 | 121 | public static void writeLine(int val) 122 | { 123 | System.out.println(val); 124 | } 125 | 126 | public static void writeLine(String format, Object...objects) 127 | { 128 | write(format + "\n", objects); 129 | } 130 | 131 | public static void write(String format, Object...objects) 132 | { 133 | System.out.printf(format, objects); 134 | } 135 | //... 136 | } 137 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/util/ConsoleUtil.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | ConsoleUtil sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class ConsoleUtil { 7 | private ConsoleUtil() {} 8 | public static void putChars(int n, char ch) 9 | { 10 | for (int i = 0; i < n; ++i) 11 | System.out.print(ch); 12 | } 13 | 14 | public static void putCharsLine(int n, char ch) 15 | { 16 | putChars(n, ch); 17 | System.out.println(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/util/IntValue.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | IntValue sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class IntValue { 7 | private final int m_val; 8 | private static final IntValue [] MS_CACHE = new IntValue[256]; 9 | 10 | private IntValue(int val) 11 | { 12 | m_val = val; 13 | } 14 | 15 | public static final IntValue ONE = of(1); 16 | public static final IntValue ZERO = of(0); 17 | public static final IntValue TEN = of(10); 18 | 19 | public static IntValue of(int val) 20 | { 21 | if (val < -128 || val > 127) 22 | return new IntValue(val); 23 | 24 | if (MS_CACHE[val + 128] == null) //ön bellekte var mı? Yoksa nesneyi yarat 25 | MS_CACHE[val + 128] = new IntValue(val); 26 | 27 | return MS_CACHE[val + 128]; 28 | } 29 | 30 | public int getVal() 31 | { 32 | return m_val; 33 | } 34 | 35 | public int compareTo(IntValue other) 36 | { 37 | return m_val - other.m_val; 38 | } 39 | 40 | public IntValue inc() 41 | { 42 | return inc(1); 43 | } 44 | 45 | public IntValue inc(int val) 46 | { 47 | return of(m_val + val); 48 | } 49 | 50 | public String toString() 51 | { 52 | return m_val + ""; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/util/Pair.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Pair sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class Pair { 7 | private final F m_first; 8 | private final S m_second; 9 | 10 | public static Pair create(F first, S second) 11 | { 12 | return new Pair<>(first, second); 13 | } 14 | 15 | public Pair(F first, S second) 16 | { 17 | m_first = first; 18 | m_second = second; 19 | } 20 | 21 | public F getFirst() 22 | { 23 | return m_first; 24 | } 25 | 26 | public S getSecond() 27 | { 28 | return m_second; 29 | } 30 | 31 | //... 32 | public String toString() 33 | { 34 | return String.format("{First: %s, Second: %s}", m_first, m_second); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/util/StringSplitOptions.java: -------------------------------------------------------------------------------- 1 | package org.csystem.util; 2 | 3 | public enum StringSplitOptions { 4 | NONE, REMOVE_EMPTY_ENTRIES 5 | } 6 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/util/Triple.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Triple sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class Triple { 7 | private final F m_first; 8 | private final S m_second; 9 | private final T m_third; 10 | 11 | public static Triple create(F first, S second, T third) 12 | { 13 | return new Triple<>(first, second, third); 14 | } 15 | 16 | public Triple(F first, S second, T third) 17 | { 18 | m_first = first; 19 | m_second = second; 20 | m_third = third; 21 | } 22 | 23 | public F getFirst() 24 | { 25 | return m_first; 26 | } 27 | 28 | public S getSecond() 29 | { 30 | return m_second; 31 | } 32 | public T getThird() 33 | { 34 | return m_third; 35 | } 36 | 37 | //... 38 | public String toString() 39 | { 40 | return String.format("{First: %s, Second: %s, Third: %s}", m_first, m_second, m_third); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/util/Unit.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Unit sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class Unit { 7 | private final T m_t; 8 | 9 | public static Unit create(T t) 10 | { 11 | return new Unit<>(t); 12 | } 13 | public Unit(T t) 14 | { 15 | m_t = t; 16 | } 17 | 18 | public T getT() 19 | { 20 | return m_t; 21 | } 22 | 23 | public String toString() 24 | { 25 | return String.format("%s", m_t); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/util/collection/CSDArrayList.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | CSDArrayList sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util.collection; 5 | 6 | public class CSDArrayList { 7 | private static final int DEFAULT_CAPACITY = 10; 8 | private E [] m_elements; 9 | private int m_index; 10 | 11 | private static void doWorkForCapacityException(String msg) 12 | { 13 | throw new IllegalArgumentException(msg); 14 | } 15 | 16 | private static void doWorkForIndexExceptionn(String msg) 17 | { 18 | throw new IndexOutOfBoundsException(msg); 19 | } 20 | 21 | private static void checkCapacity(int capacity) 22 | { 23 | if (capacity < 0) 24 | doWorkForCapacityException("Invalid capacity"); 25 | } 26 | 27 | private static void checkIndex(int index, int bound, String msg) 28 | { 29 | if (index < 0 || index >= bound) 30 | doWorkForIndexExceptionn(msg); 31 | } 32 | 33 | private void allocateCapacity(int capacity) 34 | { 35 | E [] temp = (E []) new Object[capacity]; 36 | 37 | for (int i = 0; i < m_index; ++i) 38 | temp[i] = m_elements[i]; 39 | 40 | m_elements = temp; 41 | } 42 | 43 | public CSDArrayList() 44 | { 45 | m_elements = (E[])new Object[DEFAULT_CAPACITY]; 46 | } 47 | 48 | public CSDArrayList(int initialCapacity) 49 | { 50 | checkCapacity(initialCapacity); 51 | m_elements = (E[])new Object[initialCapacity]; 52 | } 53 | 54 | public boolean add(E elem) 55 | { 56 | if (m_index == m_elements.length) 57 | this.allocateCapacity(m_elements.length == 0 ? 1 : m_elements.length * 2); 58 | 59 | m_elements[m_index++] = elem; 60 | 61 | return true; 62 | } 63 | 64 | public void add(int index, E elem) 65 | { 66 | if (m_index == m_elements.length) 67 | this.allocateCapacity(m_elements.length == 0 ? 1 : m_elements.length * 2); 68 | 69 | //TODO: 70 | } 71 | 72 | public int capacity() 73 | { 74 | return m_elements.length; 75 | } 76 | 77 | public void clear() 78 | { 79 | for (int i = 0; i < m_index; ++i) 80 | m_elements[i] = null; 81 | 82 | m_index = 0; 83 | } 84 | 85 | public E get(int index) 86 | { 87 | checkIndex(index, m_index, String.format("Invalid index:%d", index)); 88 | 89 | return m_elements[index]; 90 | } 91 | 92 | public boolean isEmpty() 93 | { 94 | return m_index == 0; 95 | } 96 | 97 | public boolean isNotEmpty() 98 | { 99 | return !isEmpty(); 100 | } 101 | 102 | public Object set(int index, E elem) 103 | { 104 | checkIndex(index, m_index, String.format("Invalid index:%d", index)); 105 | 106 | Object oldElem = m_elements[index]; 107 | 108 | m_elements[index] = elem; 109 | 110 | return oldElem; 111 | } 112 | 113 | public E remove(int index) 114 | { 115 | //... 116 | E oldElem = m_elements[index]; 117 | 118 | //TODO: 119 | 120 | return oldElem; 121 | } 122 | 123 | public int size() 124 | { 125 | return m_index; 126 | } 127 | 128 | public void trimToSize() 129 | { 130 | if (m_index == 0) 131 | m_elements = (E []) new Object[0]; 132 | else 133 | allocateCapacity(m_index); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/util/datetime/DateTimeException.java: -------------------------------------------------------------------------------- 1 | package org.csystem.util.datetime; 2 | 3 | public class DateTimeException extends RuntimeException { 4 | public DateTimeException(String message) 5 | { 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/util/datetime/DayOfWeek.java: -------------------------------------------------------------------------------- 1 | package org.csystem.util.datetime; 2 | 3 | public enum DayOfWeek { 4 | SUN, MON, TUE, WED, THU, FRI, SAT 5 | } 6 | -------------------------------------------------------------------------------- /JavaAppLesson001/org/csystem/util/datetime/Month.java: -------------------------------------------------------------------------------- 1 | package org.csystem.util.datetime; 2 | 3 | public enum Month { 4 | JAN(31), FEB(28), MAR(31), APR(30), MAY(31), JUN(30), 5 | JUL(31), AUG(31), SEP(30), OCT(31), NOV(30), DEC(31); 6 | 7 | private int m_days; 8 | 9 | Month(int days) 10 | { 11 | m_days = days; 12 | } 13 | 14 | static boolean isLeapYear(int year) 15 | { 16 | return year % 4 == 0 && year % 100 != 0 || year % 400 == 0; 17 | } 18 | 19 | int getDaysByYear(int year) 20 | { 21 | return ordinal() == 1 && isLeapYear(year) ? 29 : m_days; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/App.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Aşağıdaki örnekte komut satırı argümanı verilmemişse klavyeden giriş yapılabilecek 3 | bir program yazılmıştır 4 | ----------------------------------------------------------------------------------------------------------------------*/ 5 | package org.csystem.app; 6 | 7 | import org.csystem.util.Console; 8 | import org.csystem.util.StringUtil; 9 | 10 | class App { 11 | public static void main(String [] args) 12 | { 13 | if (args.length > 1) { 14 | Console.Error.writeLine("Argument can not be greater than 1(one)"); 15 | System.exit(-1); 16 | } 17 | 18 | var arg = args.length == 0 ? Console.read("Input your text:") : args[0]; 19 | 20 | Console.writeLine(StringUtil.isPalindrome(arg) ? "Palindrome" : "Not a palindrome"); 21 | Console.writeLine("Copyleft C and System Programmers Association"); 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/centrallimittheorem/CentralLimitTheoremSimulation.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | CentralLimitTheoremSimulation sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | 5 | package org.csystem.app.samples.centrallimittheorem; 6 | 7 | import org.csystem.util.ArrayUtil; 8 | 9 | import java.util.Random; 10 | 11 | public class CentralLimitTheoremSimulation { 12 | private final int m_max; 13 | private final int m_sampleCount; 14 | private final int m_count; 15 | private final int m_divisor; 16 | private final int [] m_counts; 17 | private final Random m_random; 18 | 19 | private double getSamplesAverage() 20 | { 21 | double sum = 0; 22 | 23 | for (int i = 0; i < m_sampleCount; ++i) 24 | sum += m_random.nextInt(m_max + 1); 25 | 26 | return sum / m_sampleCount; 27 | } 28 | 29 | private void start() 30 | { 31 | for (int i = 0; i < m_count; ++i) { 32 | double avg = getSamplesAverage(); 33 | 34 | ++m_counts[(int)avg / m_divisor]; 35 | } 36 | } 37 | 38 | public CentralLimitTheoremSimulation(int max, int sampleCount, int count, int n) 39 | { 40 | //... 41 | m_max = max; 42 | m_sampleCount = sampleCount; 43 | m_count = count; 44 | m_counts = new int[n]; 45 | m_random = new Random(); 46 | m_divisor = m_max / m_counts.length; 47 | } 48 | 49 | public void run(int n, char ch) 50 | { 51 | start(); 52 | ArrayUtil.display(m_counts); 53 | ArrayUtil.drawHistogram(m_counts, n, ch); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/centrallimittheorem/CentralLimitTheoremSimulationApp.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | CentralLimitTheoremSimulationApp sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.app.samples.centrallimittheorem; 5 | 6 | public class CentralLimitTheoremSimulationApp { 7 | public static void run() 8 | { 9 | CentralLimitTheoremSimulation clt = new CentralLimitTheoremSimulation(10000, 5, 100_000_000, 10); 10 | 11 | clt.run(20, 'X'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/commandpromptapp/CommandPrompt.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.commandpromptapp; 2 | 3 | import org.csystem.util.ArrayUtil; 4 | import org.csystem.util.StringUtil; 5 | 6 | import java.util.Scanner; 7 | 8 | public class CommandPrompt { 9 | private String m_prompt; 10 | private static final String [] MS_COMMANDS = {"length", "reverse", "upper", "lower", "prompt", "clear", "quit"}; 11 | 12 | private void doWorkForCommand(int i, String [] cmds) 13 | { 14 | switch (MS_COMMANDS[i]) { 15 | case "length": 16 | lengthProc(cmds); 17 | break; 18 | case "reverse": 19 | reverseProc(cmds); 20 | break; 21 | case "upper": 22 | upperProc(cmds); 23 | break; 24 | case "lower": 25 | lowerProc(cmds); 26 | break; 27 | case "prompt": 28 | promptProc(cmds); 29 | break; 30 | case "clear": 31 | clearProc(cmds); 32 | break; 33 | case "quit": 34 | quitProc(cmds); 35 | break; 36 | } 37 | } 38 | 39 | private void doWorkForCommands(String [] cmds) 40 | { 41 | if (cmds[0].length() < 3) { 42 | System.out.println("Komut en az 3 karakterli olmalıdır"); 43 | return; 44 | } 45 | int i; 46 | 47 | for (i = 0; i < MS_COMMANDS.length; ++i) 48 | if (MS_COMMANDS[i].startsWith(cmds[0])) { 49 | doWorkForCommand(i, cmds); 50 | break; 51 | } 52 | 53 | if (i == MS_COMMANDS.length) 54 | System.out.println("Geçersiz komut"); 55 | } 56 | 57 | private void lengthProc(String [] cmds) 58 | { 59 | String s = ArrayUtil.join(cmds, 1, ' '); 60 | 61 | System.out.println(s.length()); 62 | } 63 | 64 | private void reverseProc(String [] cmds) 65 | { 66 | String s = ArrayUtil.join(cmds, 1, ' '); 67 | 68 | System.out.println(StringUtil.reverse(s)); 69 | } 70 | 71 | private void upperProc(String [] cmds) 72 | { 73 | String s = ArrayUtil.join(cmds, 1, ' '); 74 | 75 | System.out.println(s.toUpperCase()); 76 | } 77 | 78 | private void lowerProc(String [] cmds) 79 | { 80 | String s = ArrayUtil.join(cmds, 1, ' '); 81 | 82 | System.out.println(s.toLowerCase()); 83 | } 84 | 85 | private void promptProc(String [] cmds) 86 | { 87 | String s = ArrayUtil.join(cmds, 1, ' '); 88 | 89 | m_prompt = s; 90 | } 91 | 92 | private void clearProc(String [] cmds) 93 | { 94 | if (cmds.length > 1) { 95 | System.out.println("clear komutu tek başına kullanılmalıdır"); 96 | return; 97 | } 98 | 99 | for (int i = 0; i < 30; ++i) 100 | System.out.println(); 101 | } 102 | 103 | private void quitProc(String [] cmds) 104 | { 105 | if (cmds.length > 1) { 106 | System.out.println("quit komutu tek başına yazılmalıdır"); 107 | return; 108 | } 109 | System.out.println("Copyleft @ C ve Sistem Programcıları Derneği"); 110 | System.out.println("Tekrar yapıyor musunuz?"); 111 | System.exit(0); 112 | } 113 | 114 | public CommandPrompt(String prompt) 115 | { 116 | m_prompt = prompt; 117 | } 118 | 119 | public void run() 120 | { 121 | Scanner kb = new Scanner(System.in); 122 | 123 | for (;;) { 124 | System.out.print(m_prompt + ">"); 125 | String cmdStr = kb.nextLine(); 126 | 127 | String [] cmds = cmdStr.split("[ \t]+"); 128 | 129 | doWorkForCommands(cmds); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/commandpromptapp/CommandPromptApp.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | CommandPromptApp sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.app.samples.commandpromptapp; 5 | 6 | public class CommandPromptApp { 7 | private CommandPromptApp() {} 8 | public static void run() 9 | { 10 | CommandPrompt cp = new CommandPrompt("CSD"); 11 | 12 | cp.run(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/companyapp/CompanyApp.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public class CompanyApp { 4 | public static void run() 5 | { 6 | HumanResources humanResources = new HumanResources(); 7 | Worker worker = new Worker("12345678912", "Ali", "mecidiyeköy", 60.5, 8); 8 | 9 | humanResources.payInsurance(worker); 10 | 11 | Manager manager = new Manager("12345676542", "Veli", "Fatih", "yazılım", 200000); 12 | 13 | humanResources.payInsurance(manager); 14 | 15 | ProjectWorker projectWorker = new ProjectWorker("12356789348", "Selami", "şişli", 60.5, 8, "Okul otomasyonu"); 16 | 17 | humanResources.payInsurance(projectWorker); 18 | 19 | SalesManager salesManager = new SalesManager("12345676548", "Ayşe", "Beylikdüzü", "yazılım", 10000, 3000); 20 | 21 | humanResources.payInsurance(salesManager); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/companyapp/Employee.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public abstract class Employee { 4 | private String m_citizenId; 5 | private String m_name; 6 | private String m_address; 7 | //... 8 | 9 | protected Employee(String citizenId, String name, String address) 10 | { 11 | m_citizenId = citizenId; 12 | m_name = name; 13 | m_address = address; 14 | } 15 | 16 | public String getCitizenId() 17 | { 18 | return m_citizenId; 19 | } 20 | 21 | public void setCitizenId(String citizenId) 22 | { 23 | m_citizenId = citizenId; 24 | } 25 | 26 | public String getName() 27 | { 28 | return m_name; 29 | } 30 | 31 | public void setName(String name) 32 | { 33 | m_name = name; 34 | } 35 | 36 | public String getAddress() 37 | { 38 | return m_address; 39 | } 40 | 41 | public void setAddress(String address) 42 | { 43 | m_address = address; 44 | } 45 | 46 | public abstract double calculatePayment(); 47 | } 48 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/companyapp/HumanResources.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public class HumanResources { 4 | //... 5 | public void payInsurance(Employee employee) 6 | { 7 | System.out.printf("Citizen Id:%s%n", employee.getCitizenId()); 8 | System.out.printf("Name Id:%s%n", employee.getName()); 9 | System.out.printf("Payment:%f%n", employee.calculatePayment()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/companyapp/Manager.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public class Manager extends Employee { 4 | private String m_department; 5 | private double m_salary; 6 | 7 | public Manager(String citizenId, String name, String address, String department, double salary) 8 | { 9 | super(citizenId, name, address); 10 | m_department = department; 11 | m_salary = salary; 12 | } 13 | 14 | public String getDepartment() 15 | { 16 | return m_department; 17 | } 18 | 19 | public void setDepartment(String department) 20 | { 21 | m_department = department; 22 | } 23 | 24 | public double getSalary() 25 | { 26 | return m_salary; 27 | } 28 | 29 | public void setSalary(double salary) 30 | { 31 | m_salary = salary; 32 | } 33 | public double calculatePayment() 34 | { 35 | return m_salary * m_salary * 0.5; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/companyapp/ProjectWorker.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public class ProjectWorker extends Worker { 4 | private String m_project; 5 | 6 | public ProjectWorker(String citizenId, String name, String address, double feePerHour, int hourPerDay, String project) 7 | { 8 | super(citizenId, name, address, feePerHour, hourPerDay); 9 | m_project = project; 10 | } 11 | 12 | public String getProject() 13 | { 14 | return m_project; 15 | } 16 | 17 | public void setProject(String project) 18 | { 19 | m_project = project; 20 | } 21 | 22 | public double calculatePayment() 23 | { 24 | return super.calculatePayment() + 1.5; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/companyapp/SalesManager.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public class SalesManager extends Manager { 4 | private double m_extra; 5 | 6 | public SalesManager(String citizenId, String name, String address, String department, double salary, double extra) 7 | { 8 | super(citizenId, name, address, department, salary); 9 | m_extra = extra; 10 | } 11 | 12 | public double getExtra() 13 | { 14 | return m_extra; 15 | } 16 | 17 | public void setExtra(double extra) 18 | { 19 | m_extra = extra; 20 | } 21 | 22 | public double calculatePayment() 23 | { 24 | return super.calculatePayment() + m_extra; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/companyapp/Worker.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.companyapp; 2 | 3 | public class Worker extends Employee { 4 | private double m_feePerHour; 5 | private int m_hourPerDay; 6 | 7 | public Worker(String citizenId, String name, String address, double feePerHour, int hourPerDay) 8 | { 9 | super(citizenId, name, address); 10 | //... 11 | m_feePerHour = feePerHour; 12 | m_hourPerDay = hourPerDay; 13 | } 14 | 15 | public double getFeePerHour() 16 | { 17 | return m_feePerHour; 18 | } 19 | 20 | public void setFeePerHour(double feePerHour) 21 | { 22 | m_feePerHour = feePerHour; 23 | } 24 | 25 | public int getHourPerDay() 26 | { 27 | return m_hourPerDay; 28 | } 29 | 30 | public void setHourPerDay(int hourPerDay) 31 | { 32 | m_hourPerDay = hourPerDay; 33 | } 34 | 35 | public double calculatePayment() 36 | { 37 | return m_feePerHour * m_hourPerDay * 30; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/dateapp/DateTestApp.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Sınıf Çalışması: Parametresi ile aldığı gün, ay ve yıl bilgisine ilişkin tarihin aşağıdaki açıklamalara 3 | göre yılın hangi günü olduğu bilgisini döndüren getDayOfWeek isimli metodu yazınız. 4 | Açıklamalar: 5 | - Metot geçersiz bir tarih için -1 değerine dönecektir 6 | - Metot 1900 yılından önceki tarihler için geçersiz tarih kabul edecektir. 7 | - Gün bilgisi "1.1.1900 ile verilen tarih arasındaki geçen gün sayısının 7 ile bölümünden elde 8 | edilen kalan" ile bulunabilir. Kalan değeri 0 için Pazar, 1 için Pazartesi, ..., 6 için Cumartesi 9 | olacak şekilde düşünülmelidir 10 | - Tarih bilgisi gün bilgisi ile birlikte yazdırılacaktır. Yazdırma işlemi için displayDateTR ve 11 | displayDateEN isimli Türkçe ve İngilizce olarak ekrana basan metotlar yazılarak yapılabilir 12 | - Tarih hafta sonuna geliyorsa "Bugün kurs var. Tekrar yaptınız mı?" mesajı hafta içi bir güne geliyorsa 13 | "Tekrar yapmayı unutmayınız" biçiminde mesaj yazılacaktır 14 | - İleride daha iyileri yazılacak 15 | ----------------------------------------------------------------------------------------------------------------------*/ 16 | 17 | package org.csystem.app.samples.dateapp; 18 | 19 | import org.csystem.util.datetime.Date; 20 | 21 | public class DateTestApp { 22 | private DateTestApp() {} 23 | 24 | public static void run() 25 | { 26 | java.util.Scanner kb = new java.util.Scanner(System.in); 27 | 28 | for (;;) { 29 | System.out.print("Gün?"); 30 | int day = Integer.parseInt(kb.nextLine()); 31 | 32 | if (day == 0) 33 | break; 34 | 35 | System.out.print("Ay?"); 36 | int mon = Integer.parseInt(kb.nextLine()); 37 | 38 | System.out.print("Yıl?"); 39 | int year = Integer.parseInt(kb.nextLine()); 40 | 41 | Date date = new Date(day, mon, year); 42 | 43 | System.out.println(date.toLongDateStringTR()); 44 | System.out.println(date.toLongDateStringEN()); 45 | 46 | if (date.isWeekend()) 47 | System.out.println("Bugün kurs var tekrar yaptnız mı?"); 48 | else 49 | System.out.println("Hafta sonu kurs var tekrar yapmayı unutmayınız!!!"); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/dateapp/DateUtil.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.dateapp; 2 | 3 | public class DateUtil { 4 | private static int [] ms_daysOfMonths = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 5 | private static String [] ms_weekDaysTR = {"Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"}; 6 | private static String [] ms_weekDaysEN = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; 7 | private static String [] ms_monthsTR = {"", "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", 8 | "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"}; 9 | private static String [] ms_monthsEN = {"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; 10 | 11 | private DateUtil() {} 12 | 13 | public static void displayDateTR(int day, int mon, int year) 14 | { 15 | int dayOfWeek = getDayOfWeek(day, mon, year); 16 | 17 | if (dayOfWeek == -1) { 18 | System.out.println("Geçersiz tarih"); 19 | return; 20 | } 21 | 22 | System.out.printf("%02d %s %04d %s%n", day, ms_monthsTR[mon], year, ms_weekDaysTR[dayOfWeek]); 23 | 24 | if (isWeekend(day, mon, year)) 25 | System.out.println("Bugün kurs var. Tekrar yaptınız mı?"); 26 | else 27 | System.out.println("Tekrar yapmayı unutmayınız!!!"); 28 | } 29 | 30 | public static void displayDateEN(int day, int mon, int year) 31 | { 32 | int dayOfWeek = getDayOfWeek(day, mon, year); 33 | 34 | if (dayOfWeek == -1) { 35 | System.out.println("Geçersiz tarih"); 36 | return; 37 | } 38 | 39 | System.out.printf("%02d %s %04d %s%n", day, ms_monthsEN[mon], year, ms_weekDaysEN[dayOfWeek]); 40 | } 41 | 42 | public static boolean isWeekend(int day, int mon, int year) 43 | { 44 | int dayOfWeek = getDayOfWeek(day, mon, year); 45 | 46 | //... 47 | 48 | return dayOfWeek == 0 || dayOfWeek == 6; 49 | } 50 | 51 | public static boolean isWeekday(int day, int mon, int year) 52 | { 53 | return !isWeekend(day, mon, year); 54 | } 55 | 56 | public static int getDayOfWeek(int day, int mon, int year) 57 | { 58 | int dayOfYear = getDayOfYear(day, mon, year); 59 | 60 | if (dayOfYear == -1 || year < 1900) 61 | return -1; 62 | 63 | int totalDays = dayOfYear; 64 | 65 | for (int y = 1900; y < year; ++y) 66 | totalDays += isLeapYear(y) ? 366 : 365; 67 | 68 | return totalDays % 7; 69 | } 70 | 71 | public static int getDayOfYear(int day, int mon, int year) 72 | { 73 | if (!isValidDate(day, mon, year)) 74 | return -1; 75 | 76 | int dayOfYear = day; 77 | 78 | for (int m = mon - 1; m >= 1; --m) 79 | dayOfYear += ms_daysOfMonths[m]; 80 | 81 | if (mon > 2 && isLeapYear(year)) 82 | ++dayOfYear; 83 | 84 | return dayOfYear; 85 | } 86 | 87 | public static boolean isValidDate(int day, int mon, int year) 88 | { 89 | if (day < 1 || day > 31 || mon < 1 || mon > 12) 90 | return false; 91 | 92 | int days = mon == 2 && isLeapYear(year) ? 29 : ms_daysOfMonths[mon]; 93 | 94 | return day <= days; 95 | } 96 | 97 | public static boolean isLeapYear(int year) 98 | { 99 | return year % 4 == 0 && year % 100 != 0 || year % 400 == 0; 100 | } 101 | } -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/dateapp/DateUtilTestApp.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Sınıf Çalışması: Parametresi ile aldığı gün, ay ve yıl bilgisine ilişkin tarihin aşağıdaki açıklamalara 3 | göre yılın hangi günü olduğu bilgisini döndüren getDayOfWeek isimli metodu yazınız. 4 | Açıklamalar: 5 | - Metot geçersiz bir tarih için -1 değerine dönecektir 6 | - Metot 1900 yılından önceki tarihler için geçersiz tarih kabul edecektir. 7 | - Gün bilgisi "1.1.1900 ile verilen tarih arasındaki geçen gün sayısının 7 ile bölümünden elde 8 | edilen kalan" ile bulunabilir. Kalan değeri 0 için Pazar, 1 için Pazartesi, ..., 6 için Cumartesi 9 | olacak şekilde düşünülmelidir 10 | - Tarih bilgisi gün bilgisi ile birlikte yazdırılacaktır. Yazdırma işlemi için displayDateTR ve 11 | displayDateEN isimli Türkçe ve İngilizce olarak ekrana basan metotlar yazılarak yapılabilir 12 | - Tarih hafta sonuna geliyorsa "Bugün kurs var. Tekrar yaptınız mı?" mesajı hafta içi bir güne geliyorsa 13 | "Tekrar yapmayı unutmayınız" biçiminde mesaj yazılacaktır 14 | - İleride daha iyileri yazılacak 15 | ----------------------------------------------------------------------------------------------------------------------*/ 16 | 17 | package org.csystem.app.samples.dateapp; 18 | 19 | public class DateUtilTestApp { 20 | private DateUtilTestApp() {} 21 | 22 | public static void run() 23 | { 24 | java.util.Scanner kb = new java.util.Scanner(System.in); 25 | 26 | for (;;) { 27 | System.out.print("Gün?"); 28 | int day = Integer.parseInt(kb.nextLine()); 29 | 30 | if (day == 0) 31 | break; 32 | 33 | System.out.print("Ay?"); 34 | int mon = Integer.parseInt(kb.nextLine()); 35 | 36 | System.out.print("Yıl?"); 37 | int year = Integer.parseInt(kb.nextLine()); 38 | 39 | DateUtil.displayDateTR(day, mon, year); 40 | DateUtil.displayDateEN(day, mon, year); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/examsimulationapp/ExamSimulation.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.examsimulationapp; 2 | 3 | import org.csystem.util.ArrayUtil; 4 | import org.csystem.util.ConsoleUtil; 5 | 6 | import java.util.Random; 7 | import java.util.Scanner; 8 | 9 | public class ExamSimulation { 10 | private final String m_lectureName; 11 | private int [][] m_grades; 12 | private double [] m_averages; 13 | private double average; 14 | 15 | public void fillGrades(Scanner kb) 16 | { 17 | Random r = new Random(); 18 | 19 | for (int i = 0; i < m_grades.length; ++i) { 20 | System.out.printf("%d. şube öğrenci sayısını giriniz:", i + 1); 21 | m_grades[i] = ArrayUtil.getRandomArray(r, Integer.parseInt(kb.nextLine()), 0, 101); 22 | } 23 | } 24 | 25 | public void createGradesInfo() 26 | { 27 | Scanner kb = new Scanner(System.in); 28 | System.out.printf("'%s' sınavı şube sayısını giriniz:", m_lectureName); 29 | int n = Integer.parseInt(kb.nextLine()); 30 | 31 | m_grades = new int[n][]; 32 | m_averages = new double[n]; 33 | 34 | fillGrades(kb); 35 | } 36 | 37 | public void calculateAverages() 38 | { 39 | int totalGrade = 0; 40 | int numberOfStudents = 0; 41 | 42 | for (int i = 0; i < m_grades.length; ++i) { 43 | int sumOfGrades = ArrayUtil.sum(m_grades[i]); 44 | 45 | totalGrade += sumOfGrades; 46 | numberOfStudents += m_grades[i].length; 47 | m_averages[i] = (double)sumOfGrades / m_grades[i].length; 48 | } 49 | 50 | average = (double)totalGrade / numberOfStudents; 51 | } 52 | 53 | public void displayHeader() 54 | { 55 | String fmt = String.format("%n%s DERSİ SINAV RAPORU:%n", m_lectureName); 56 | System.out.printf(fmt, m_lectureName); 57 | ConsoleUtil.putCharsLine(fmt.length(), '-'); 58 | } 59 | 60 | public void displayGrades() 61 | { 62 | System.out.println("Şube Notları:"); 63 | ConsoleUtil.putCharsLine(13, '-'); 64 | 65 | for (int i = 0; i < m_grades.length; ++i) { 66 | System.out.printf("%d. şube notlar:%n", i + 1); 67 | ArrayUtil.display(2, m_grades[i]); 68 | } 69 | } 70 | 71 | public void displayAverages() 72 | { 73 | System.out.println("Ortalamalar:"); 74 | ConsoleUtil.putCharsLine(13, '-'); 75 | for (int i = 0; i < m_averages.length; ++i) 76 | System.out.printf("%d. şube ortalaması:%f%n", i + 1, m_averages[i]); 77 | 78 | System.out.printf("Okul ortalaması:%f%n", average); 79 | } 80 | 81 | public ExamSimulation(String name) 82 | { 83 | m_lectureName = name; 84 | } 85 | 86 | public void displayReport() 87 | { 88 | displayHeader(); 89 | displayGrades(); 90 | displayAverages(); 91 | System.out.println("///////////////////////////"); 92 | } 93 | 94 | public void run() 95 | { 96 | createGradesInfo(); 97 | calculateAverages(); 98 | } 99 | 100 | // 101 | } 102 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/examsimulationapp/ExamSimulationApp.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.examsimulationapp; 2 | 3 | public class ExamSimulationApp { 4 | private ExamSimulationApp() {} 5 | public static void run() 6 | { 7 | ExamSimulation [] examSimulations = {new ExamSimulation("Matematik"), new ExamSimulation("Kimya")}; 8 | 9 | for (int i = 0; i < examSimulations.length; ++i) 10 | examSimulations[i].run(); 11 | 12 | for (int i = 0; i < examSimulations.length; ++i) 13 | examSimulations[i].displayReport(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/lottaryapp/Lottary.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.lottaryapp; 2 | 3 | import java.util.Random; 4 | 5 | public class Lottary { 6 | private Random m_random; 7 | 8 | private static int [] getNumbers(boolean [] flags) 9 | { 10 | int [] numbers = new int[6]; 11 | 12 | int index = 0; 13 | 14 | for (int i = 1; i < 50; ++i) 15 | if (flags[i]) 16 | numbers[index++] = i; 17 | 18 | return numbers; 19 | } 20 | 21 | private boolean [] getFlags() 22 | { 23 | boolean [] flags = new boolean[50]; 24 | int val; 25 | 26 | for (int i = 0; i < 6; ++i) { 27 | for (;;) { 28 | val = m_random.nextInt(49) + 1; 29 | if (!flags[val]) 30 | break; 31 | } 32 | flags[val] = true; 33 | } 34 | 35 | return flags; 36 | } 37 | 38 | public Lottary() 39 | { 40 | this(new Random()); 41 | } 42 | 43 | public Lottary(Random r) 44 | { 45 | m_random = r; 46 | } 47 | 48 | public int [] getNumbers() 49 | { 50 | return getNumbers(getFlags()); 51 | } 52 | 53 | public int [][] getNumbers(int n) 54 | { 55 | int [][] a = new int[n][]; 56 | 57 | for (int i = 0; i < n; ++i) 58 | a[i] = getNumbers(); 59 | 60 | return a; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/lottaryapp/LottaryTest.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.lottaryapp; 2 | 3 | import org.csystem.util.ArrayUtil; 4 | 5 | import java.util.Scanner; 6 | 7 | public class LottaryTest { 8 | private LottaryTest() {} 9 | public static void run() 10 | { 11 | Scanner kb = new Scanner(System.in); 12 | System.out.print("Kaç kupon oynamak istiyorsunuz?"); 13 | int n = Integer.parseInt(kb.nextLine()); 14 | 15 | Lottary lottary = new Lottary(); 16 | 17 | ArrayUtil.display(2, lottary.getNumbers(n)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/parserapp/CharArraySource.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.parserapp; 2 | 3 | public class CharArraySource implements ISource { 4 | private final char[] m_chars; 5 | private int m_index; 6 | 7 | public CharArraySource(String string) 8 | { 9 | m_chars = string.toCharArray(); 10 | } 11 | 12 | public int getChar() 13 | { 14 | return m_index == m_chars.length ? -1 : m_chars[m_index++]; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/parserapp/ISource.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.parserapp; 2 | 3 | public interface ISource { 4 | int getChar(); 5 | } 6 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/parserapp/Parser.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.parserapp; 2 | 3 | public class Parser { 4 | private ISource m_source; 5 | 6 | public Parser(ISource source) 7 | { 8 | //... 9 | m_source = source; 10 | } 11 | 12 | public ISource getSource() 13 | { 14 | return m_source; 15 | } 16 | 17 | public void setSource(ISource source) 18 | { 19 | m_source = source; 20 | } 21 | 22 | public void doParse() 23 | { 24 | int count = 0; 25 | int ch; 26 | 27 | while ((ch = m_source.getChar()) != -1) 28 | if (Character.isLetter((char)ch)) 29 | ++count; 30 | 31 | System.out.printf("Count:%d%n", count); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/parserapp/ParserApp.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.parserapp; 2 | 3 | public class ParserApp { 4 | public static void run() 5 | { 6 | StringSource stringSource = new StringSource("bugün hava 25 derece"); 7 | Parser parser = new Parser(stringSource); 8 | 9 | parser.doParse(); 10 | 11 | CharArraySource charArraySource = new CharArraySource("Ali Serçe"); 12 | 13 | parser.setSource(charArraySource); 14 | 15 | parser.doParse(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/parserapp/StringSource.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.parserapp; 2 | 3 | public class StringSource implements ISource { 4 | private final String m_str; 5 | private int m_index; 6 | 7 | public StringSource(String str) 8 | { 9 | m_str = str; 10 | } 11 | 12 | public int getChar() 13 | { 14 | return m_index == m_str.length() ? -1 : m_str.charAt(m_index++); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/randomobjectsgeneratorapp/RandomObjectsGenerator.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.randomobjectsgeneratorapp; 2 | 3 | import org.csystem.util.IntValue; 4 | import org.csystem.util.StringUtil; 5 | import org.csystem.util.datetime.Date; 6 | import org.csystem.util.datetime.Time; 7 | 8 | import java.util.Random; 9 | 10 | public class RandomObjectsGenerator { 11 | private Random m_random; 12 | private Object [] m_objects; 13 | 14 | public Object getRandomObject() 15 | { 16 | Object result = IntValue.of(m_random.nextInt(255) - 128); 17 | 18 | switch (m_random.nextInt(6)) { 19 | case 0: 20 | result = Date.randomDate(m_random); 21 | break; 22 | case 1: 23 | result = StringUtil.getRandomTextEN(m_random, m_random.nextInt(10)); 24 | break; 25 | case 2: 26 | result = Time.randomLongTime(m_random); 27 | break; 28 | case 3: 29 | result = m_random.nextInt(101); //auto-boxing 30 | break; 31 | case 4: 32 | result = m_random.nextDouble(); //auto-boxing 33 | break; 34 | } 35 | 36 | return result; 37 | } 38 | 39 | public RandomObjectsGenerator(int count) 40 | { 41 | this(new Random(), count); 42 | } 43 | 44 | public RandomObjectsGenerator(Random random, int count) 45 | { 46 | m_random = random; 47 | m_objects = new Object[count]; 48 | } 49 | 50 | public Object[] getObjects() 51 | { 52 | return m_objects; 53 | } 54 | 55 | public void generate() 56 | { 57 | for (int i = 0; i < m_objects.length; ++i) 58 | m_objects[i] = getRandomObject(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/randomobjectsgeneratorapp/RandomObjectsGeneratorApp.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.randomobjectsgeneratorapp; 2 | 3 | import org.csystem.util.IntValue; 4 | import org.csystem.util.datetime.Date; 5 | import org.csystem.util.datetime.Time; 6 | 7 | import java.util.Random; 8 | import java.util.Scanner; 9 | 10 | public class RandomObjectsGeneratorApp { 11 | private static void dateProc(Date date) 12 | { 13 | System.out.println("Date:"); 14 | System.out.println(date.toLongDateStringEN()); 15 | System.out.println(date.toLongDateStringTR()); 16 | 17 | } 18 | private static void timeProc(Time time) 19 | { 20 | System.out.println("Time:"); 21 | System.out.println(time.toLongTimeString()); 22 | } 23 | 24 | private static void intValueProc(IntValue intValue) 25 | { 26 | System.out.println("IntValue:"); 27 | System.out.println(intValue.getVal()); 28 | System.out.println(intValue.inc(5).getVal()); 29 | } 30 | 31 | private static void stringProc(String str) 32 | { 33 | System.out.println("String:"); 34 | System.out.println(str); 35 | System.out.println(str.toUpperCase()); 36 | } 37 | 38 | private static void integerProc(int val) 39 | { 40 | System.out.println("Integer:"); 41 | System.out.printf("%d * %d = %d%n", val, val, val * val); 42 | } 43 | 44 | private static void doubleProc(double val) 45 | { 46 | System.out.println("Double:"); 47 | 48 | System.out.println(val); 49 | } 50 | 51 | private static void doWork(RandomObjectsGenerator randomObjectsGenerator) 52 | { 53 | randomObjectsGenerator.generate(); 54 | for (Object object : randomObjectsGenerator.getObjects()) { 55 | if (object instanceof Date) 56 | dateProc((Date)object); 57 | else if (object instanceof Time) 58 | timeProc((Time)object); 59 | else if (object instanceof IntValue) 60 | intValueProc((IntValue)object); 61 | else if (object instanceof String) 62 | stringProc((String)object); 63 | else if (object instanceof Integer) 64 | integerProc((int)object); 65 | else 66 | doubleProc((double)object); 67 | } 68 | } 69 | 70 | public static void run() 71 | { 72 | Scanner kb = new Scanner(System.in); 73 | System.out.print("Dizinin eleman sayısını giriniz"); 74 | int count = Integer.parseInt(kb.nextLine()); 75 | Random r = new Random(); 76 | RandomObjectsGenerator randomObjectsGenerator = new RandomObjectsGenerator(r, count); 77 | 78 | doWork(randomObjectsGenerator); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/sentenceterminalapp/SentenceTerminal.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Sınıf Çalışması: Aşağıdaki gibi çalışan bir komut yorumlayıcı program yazınız. 3 | Açıklamalar: 4 | - Program bir komut yorumlayıcı olarak aşağıdaki komutlar kabul edecektir. 5 | - stat 6 | - quit 7 | - stat komutundan sonra bir cümle gelmelidir. Cümlenn isogram, değilse pangram değilse hiçbiri olarak 8 | sonucu elde edilecektir 9 | 10 | > stat abcdefghijklm nopqrstuwxvyz 11 | isogram 12 | > stat abcdefghijklmno ......pqrsatuwxvyz 13 | pangram 14 | > stat abcdefghijklmnopqrtuw ....xvyz 15 | nothing 16 | - Sadece İngilizce alfabedeki karakterler gözönüne alınacaktır
 17 | ----------------------------------------------------------------------------------------------------------------------*/ 18 | package org.csystem.app.samples.sentenceterminalapp; 19 | 20 | import org.csystem.util.ArrayUtil; 21 | 22 | import java.util.Scanner; 23 | 24 | public class SentenceTerminal { 25 | private final String m_prompt; 26 | private String m_cmd; 27 | 28 | private void fillCounts(int [] counts, String sentence) 29 | { 30 | int len = sentence.length(); 31 | 32 | for (int i = 0; i < len; ++i) { 33 | char c = Character.toLowerCase(sentence.charAt(i)); 34 | if (c < 'a' || c > 'z') 35 | continue; 36 | 37 | ++counts[c - 'a']; 38 | } 39 | } 40 | 41 | private void displayStatus(int [] counts) 42 | { 43 | boolean isPangram = false; 44 | 45 | for (int val : counts) { 46 | if (val == 0) { 47 | System.out.println("Nothing"); 48 | return; 49 | } 50 | if (val > 1) 51 | isPangram = true; 52 | } 53 | 54 | System.out.println(isPangram ? "pangram" : "isogram"); 55 | } 56 | 57 | private void doWorkForSentence(String sentence) 58 | { 59 | int [] counts = new int[26]; 60 | 61 | fillCounts(counts, sentence); 62 | displayStatus(counts); 63 | } 64 | 65 | private void parseCommand() 66 | { 67 | String [] cmdInfo = m_cmd.split("[ \t]+"); 68 | 69 | if (!cmdInfo[0].equals("stat")) { 70 | System.out.println("Invalid command"); 71 | return; 72 | } 73 | 74 | if (cmdInfo.length == 1) { 75 | System.out.println("stat must have a sentence"); 76 | return; 77 | } 78 | 79 | String sentence = ArrayUtil.join(cmdInfo, 1, ""); 80 | 81 | doWorkForSentence(sentence); 82 | } 83 | 84 | public SentenceTerminal(String prompt) 85 | { 86 | m_prompt = prompt; 87 | } 88 | 89 | public void run() 90 | { 91 | Scanner kb = new Scanner(System.in); 92 | 93 | for (;;) { 94 | System.out.print(m_prompt + "> "); 95 | m_cmd = kb.nextLine().trim(); 96 | 97 | if (m_cmd.equals("quit")) 98 | break; 99 | 100 | parseCommand(); 101 | } 102 | 103 | System.out.println("Tekrar yapıyor musunuz?"); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/app/samples/sentenceterminalapp/SentenceTerminalApp.java: -------------------------------------------------------------------------------- 1 | package org.csystem.app.samples.sentenceterminalapp; 2 | 3 | public class SentenceTerminalApp { 4 | private SentenceTerminalApp() 5 | {} 6 | 7 | public static void run() 8 | { 9 | SentenceTerminal sentenceTerminal = new SentenceTerminal("CSD"); 10 | 11 | sentenceTerminal.run(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/math/Complex.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Complex sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math; 5 | 6 | import static java.lang.Math.sqrt; 7 | 8 | public class Complex { 9 | private static Complex add(double re1, double im1, double re2, double im2) 10 | { 11 | return new Complex(re1 + re2, im1 + im2); 12 | } 13 | 14 | private static Complex sub(double re1, double im1, double re2, double im2) 15 | { 16 | return add(re1, im1, -re2, -im2); 17 | } 18 | 19 | public double re, im; 20 | 21 | public Complex() 22 | {} 23 | 24 | public Complex(double re) 25 | { 26 | this.re = re; 27 | } 28 | 29 | public Complex(double re, double im) 30 | { 31 | this.re = re; 32 | this.im = im; 33 | } 34 | 35 | public Complex getConjugate() 36 | { 37 | Complex z = new Complex(); 38 | 39 | z.re = re; 40 | z.im = -im; 41 | 42 | return z; 43 | } 44 | 45 | public double getNorm() 46 | { 47 | return sqrt(re * re + im * im); 48 | } 49 | 50 | public static Complex add(double re, double im, Complex z) 51 | { 52 | return add(re, im, z.re, z.im); 53 | } 54 | 55 | public Complex add(Complex z) 56 | { 57 | return add(re, im, z.re, z.im); 58 | } 59 | 60 | public Complex add(double x, double y) 61 | { 62 | return add(re, im, x, y); 63 | } 64 | 65 | public static Complex sub(double re, double im, Complex z) 66 | { 67 | return sub(re, im, z.re, z.im); 68 | } 69 | 70 | public Complex sub(Complex z) 71 | { 72 | return sub(re, im, z.re, z.im); 73 | } 74 | 75 | public Complex sub(double x, double y) 76 | { 77 | return sub(re, im, x, y); 78 | } 79 | 80 | public String toString() 81 | { 82 | return String.format("|%.2f + i * %.2f| = %f", re, im, this.getNorm()); 83 | } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/math/RationalException.java: -------------------------------------------------------------------------------- 1 | package org.csystem.math; 2 | 3 | public class RationalException extends NumberFormatException { 4 | private final RationalExceptionStatus m_rationalExceptionStatus; 5 | 6 | public RationalException(String message, RationalExceptionStatus rationalExceptionStatus) 7 | { 8 | super(message); 9 | m_rationalExceptionStatus = rationalExceptionStatus; 10 | } 11 | 12 | public RationalExceptionStatus getRationalExceptionStatus() 13 | { 14 | return m_rationalExceptionStatus; 15 | } 16 | 17 | public String getMessage() 18 | { 19 | return String.format("Message:%s, Exception Status:%s", super.getMessage(), m_rationalExceptionStatus); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/math/RationalExceptionStatus.java: -------------------------------------------------------------------------------- 1 | package org.csystem.math; 2 | 3 | public enum RationalExceptionStatus { 4 | UNDEFINED, INDEFINITE 5 | } 6 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/math/geometry/AnalyticalCircle.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Analytical sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | public class AnalyticalCircle extends Circle { 7 | private Point m_center; 8 | 9 | public AnalyticalCircle() 10 | { 11 | this(0); 12 | } 13 | 14 | public AnalyticalCircle(double r) 15 | { 16 | this(r, 0, 0); 17 | } 18 | 19 | public AnalyticalCircle(Point center) 20 | { 21 | this(0, center); 22 | } 23 | 24 | public AnalyticalCircle(int x, int y) 25 | { 26 | this(0, x, y); 27 | } 28 | 29 | public AnalyticalCircle(double r, Point center) 30 | { 31 | this(r, center.x, center.y); 32 | } 33 | 34 | public AnalyticalCircle(double r, int x, int y) 35 | { 36 | super(r); 37 | m_center = new Point(x, y); 38 | } 39 | 40 | public int getX() 41 | { 42 | return m_center.x; 43 | } 44 | 45 | public void setX(int x) 46 | { 47 | m_center.x = x; 48 | } 49 | 50 | public int getY() 51 | { 52 | return m_center.y; 53 | } 54 | 55 | public void setY(int y) 56 | { 57 | m_center.y = y; 58 | } 59 | 60 | public void setCenter(Point center) 61 | { 62 | this.setCenter(center.x, center.y); 63 | } 64 | 65 | public void setCenter(int x, int y) 66 | { 67 | this.setX(x); 68 | this.setY(y); 69 | } 70 | 71 | public Point getCenter() 72 | { 73 | return new Point(m_center); 74 | } 75 | 76 | public void offset(int dx, int dy) 77 | { 78 | m_center.offset(dx, dy); 79 | } 80 | 81 | public void offset(int dxy) 82 | { 83 | this.offset(dxy, dxy); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/math/geometry/Circle.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Circle sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | public class Circle { 7 | private double m_r; 8 | 9 | public Circle() 10 | {} 11 | 12 | public Circle(double r) 13 | { 14 | this.setRadius(r); 15 | } 16 | 17 | public double getRadius() 18 | { 19 | return m_r; 20 | } 21 | 22 | public void setRadius(double r) 23 | { 24 | m_r = Math.abs(r); 25 | } 26 | 27 | public double getArea() 28 | { 29 | return Math.PI * m_r * m_r; 30 | } 31 | 32 | public double getCircumference() 33 | { 34 | return 2 * Math.PI * m_r; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/math/geometry/Point.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Point sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | import static java.lang.Math.sqrt; 7 | 8 | public class Point { 9 | public int x, y; 10 | 11 | Point(Point p) 12 | { 13 | this(p.x, p.y); 14 | } 15 | 16 | public Point() 17 | {} 18 | 19 | public Point(int x) 20 | { 21 | this(x, 0); 22 | } 23 | 24 | public Point(int x, int y) 25 | { 26 | this.x = x; 27 | this.y = y; 28 | } 29 | 30 | public double distance(Point p) 31 | { 32 | return this.distance(p.x, p.y); 33 | } 34 | 35 | public double distance(int a, int b) 36 | { 37 | return sqrt((x - a) * (x - a) + (y - b) * (y - b)); 38 | } 39 | 40 | public void offset(int dxy) 41 | { 42 | this.offset(dxy, dxy); 43 | } 44 | 45 | public void offset(int dx, int dy) 46 | { 47 | x += dx; 48 | y += dy; 49 | } 50 | 51 | public String toString() 52 | { 53 | return String.format("(%d, %d)", x, y); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/math/geometry/PointF.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | PointF sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | import static java.lang.Math.sqrt; 7 | 8 | public class PointF { 9 | public float x, y; 10 | 11 | PointF(PointF p) 12 | { 13 | this(p.x, p.y); 14 | } 15 | 16 | public PointF() 17 | {} 18 | 19 | public PointF(float re) 20 | { 21 | this(re, 0); 22 | } 23 | 24 | public PointF(float x, float y) 25 | { 26 | this.x = x; 27 | this.y = y; 28 | } 29 | 30 | public double distance(PointF p) 31 | { 32 | return this.distance(p.x, p.y); 33 | } 34 | 35 | public double distance(float a, float b) 36 | { 37 | return sqrt((x - a) * (x - a) + (y - b) * (y - b)); 38 | } 39 | 40 | public void offset(float dxy) 41 | { 42 | this.offset(dxy, dxy); 43 | } 44 | 45 | public void offset(float dx, float dy) 46 | { 47 | x += dx; 48 | y += dy; 49 | } 50 | 51 | public String toString() 52 | { 53 | return String.format("(%.2f, %.2f)", x, y); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/util/ConsoleUtil.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | ConsoleUtil sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class ConsoleUtil { 7 | private ConsoleUtil() {} 8 | public static void putChars(int n, char ch) 9 | { 10 | for (int i = 0; i < n; ++i) 11 | System.out.print(ch); 12 | } 13 | 14 | public static void putCharsLine(int n, char ch) 15 | { 16 | putChars(n, ch); 17 | System.out.println(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/util/IntValue.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | IntValue sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class IntValue { 7 | private final int m_val; 8 | private static final IntValue [] MS_CACHE = new IntValue[256]; 9 | 10 | private IntValue(int val) 11 | { 12 | m_val = val; 13 | } 14 | 15 | public static final IntValue ONE = of(1); 16 | public static final IntValue ZERO = of(0); 17 | public static final IntValue TEN = of(10); 18 | 19 | public static IntValue of(int val) 20 | { 21 | if (val < -128 || val > 127) 22 | return new IntValue(val); 23 | 24 | if (MS_CACHE[val + 128] == null) //ön bellekte var mı? Yoksa nesneyi yarat 25 | MS_CACHE[val + 128] = new IntValue(val); 26 | 27 | return MS_CACHE[val + 128]; 28 | } 29 | 30 | public int getVal() 31 | { 32 | return m_val; 33 | } 34 | 35 | public int compareTo(IntValue other) 36 | { 37 | return m_val - other.m_val; 38 | } 39 | 40 | public IntValue inc() 41 | { 42 | return inc(1); 43 | } 44 | 45 | public IntValue inc(int val) 46 | { 47 | return of(m_val + val); 48 | } 49 | 50 | public String toString() 51 | { 52 | return m_val + ""; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/util/Pair.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Pair sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class Pair { 7 | private final F m_first; 8 | private final S m_second; 9 | 10 | public static Pair create(F first, S second) 11 | { 12 | return new Pair<>(first, second); 13 | } 14 | 15 | public Pair(F first, S second) 16 | { 17 | m_first = first; 18 | m_second = second; 19 | } 20 | 21 | public F getFirst() 22 | { 23 | return m_first; 24 | } 25 | 26 | public S getSecond() 27 | { 28 | return m_second; 29 | } 30 | 31 | //... 32 | public String toString() 33 | { 34 | return String.format("{First: %s, Second: %s}", m_first, m_second); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/util/StringSplitOptions.java: -------------------------------------------------------------------------------- 1 | package org.csystem.util; 2 | 3 | public enum StringSplitOptions { 4 | NONE, REMOVE_EMPTY_ENTRIES 5 | } 6 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/util/Triple.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Triple sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class Triple { 7 | private final F m_first; 8 | private final S m_second; 9 | private final T m_third; 10 | 11 | public static Triple create(F first, S second, T third) 12 | { 13 | return new Triple<>(first, second, third); 14 | } 15 | 16 | public Triple(F first, S second, T third) 17 | { 18 | m_first = first; 19 | m_second = second; 20 | m_third = third; 21 | } 22 | 23 | public F getFirst() 24 | { 25 | return m_first; 26 | } 27 | 28 | public S getSecond() 29 | { 30 | return m_second; 31 | } 32 | public T getThird() 33 | { 34 | return m_third; 35 | } 36 | 37 | //... 38 | public String toString() 39 | { 40 | return String.format("{First: %s, Second: %s, Third: %s}", m_first, m_second, m_third); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/util/Unit.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Unit sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class Unit { 7 | private final T m_t; 8 | 9 | public static Unit create(T t) 10 | { 11 | return new Unit<>(t); 12 | } 13 | public Unit(T t) 14 | { 15 | m_t = t; 16 | } 17 | 18 | public T getT() 19 | { 20 | return m_t; 21 | } 22 | 23 | public String toString() 24 | { 25 | return String.format("%s", m_t); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/util/collection/CSDArrayList.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | CSDArrayList sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util.collection; 5 | 6 | public class CSDArrayList { 7 | private static final int DEFAULT_CAPACITY = 10; 8 | private E [] m_elements; 9 | private int m_index; 10 | 11 | private static void doWorkForCapacityException(String msg) 12 | { 13 | throw new IllegalArgumentException(msg); 14 | } 15 | 16 | private static void doWorkForIndexExceptionn(String msg) 17 | { 18 | throw new IndexOutOfBoundsException(msg); 19 | } 20 | 21 | private static void checkCapacity(int capacity) 22 | { 23 | if (capacity < 0) 24 | doWorkForCapacityException("Invalid capacity"); 25 | } 26 | 27 | private static void checkIndex(int index, int bound, String msg) 28 | { 29 | if (index < 0 || index >= bound) 30 | doWorkForIndexExceptionn(msg); 31 | } 32 | 33 | private void allocateCapacity(int capacity) 34 | { 35 | E [] temp = (E []) new Object[capacity]; 36 | 37 | for (int i = 0; i < m_index; ++i) 38 | temp[i] = m_elements[i]; 39 | 40 | m_elements = temp; 41 | } 42 | 43 | public CSDArrayList() 44 | { 45 | m_elements = (E[])new Object[DEFAULT_CAPACITY]; 46 | } 47 | 48 | public CSDArrayList(int initialCapacity) 49 | { 50 | checkCapacity(initialCapacity); 51 | m_elements = (E[])new Object[initialCapacity]; 52 | } 53 | 54 | public boolean add(E elem) 55 | { 56 | if (m_index == m_elements.length) 57 | this.allocateCapacity(m_elements.length == 0 ? 1 : m_elements.length * 2); 58 | 59 | m_elements[m_index++] = elem; 60 | 61 | return true; 62 | } 63 | 64 | public void add(int index, E elem) 65 | { 66 | if (m_index == m_elements.length) 67 | this.allocateCapacity(m_elements.length == 0 ? 1 : m_elements.length * 2); 68 | 69 | //TODO: 70 | } 71 | 72 | public int capacity() 73 | { 74 | return m_elements.length; 75 | } 76 | 77 | public void clear() 78 | { 79 | for (int i = 0; i < m_index; ++i) 80 | m_elements[i] = null; 81 | 82 | m_index = 0; 83 | } 84 | 85 | public E get(int index) 86 | { 87 | checkIndex(index, m_index, String.format("Invalid index:%d", index)); 88 | 89 | return m_elements[index]; 90 | } 91 | 92 | public boolean isEmpty() 93 | { 94 | return m_index == 0; 95 | } 96 | 97 | public boolean isNotEmpty() 98 | { 99 | return !isEmpty(); 100 | } 101 | 102 | public Object set(int index, E elem) 103 | { 104 | checkIndex(index, m_index, String.format("Invalid index:%d", index)); 105 | 106 | Object oldElem = m_elements[index]; 107 | 108 | m_elements[index] = elem; 109 | 110 | return oldElem; 111 | } 112 | 113 | public E remove(int index) 114 | { 115 | //... 116 | E oldElem = m_elements[index]; 117 | 118 | //TODO: 119 | 120 | return oldElem; 121 | } 122 | 123 | public int size() 124 | { 125 | return m_index; 126 | } 127 | 128 | public void trimToSize() 129 | { 130 | if (m_index == 0) 131 | m_elements = (E []) new Object[0]; 132 | else 133 | allocateCapacity(m_index); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/util/datetime/DateTimeException.java: -------------------------------------------------------------------------------- 1 | package org.csystem.util.datetime; 2 | 3 | public class DateTimeException extends RuntimeException { 4 | public DateTimeException(String message) 5 | { 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/util/datetime/DayOfWeek.java: -------------------------------------------------------------------------------- 1 | package org.csystem.util.datetime; 2 | 3 | public enum DayOfWeek { 4 | SUN, MON, TUE, WED, THU, FRI, SAT 5 | } 6 | -------------------------------------------------------------------------------- /JavaAppLesson002/org/csystem/util/datetime/Month.java: -------------------------------------------------------------------------------- 1 | package org.csystem.util.datetime; 2 | 3 | public enum Month { 4 | JAN(31), FEB(28), MAR(31), APR(30), MAY(31), JUN(30), 5 | JUL(31), AUG(31), SEP(30), OCT(31), NOV(30), DEC(31); 6 | 7 | private int m_days; 8 | 9 | Month(int days) 10 | { 11 | m_days = days; 12 | } 13 | 14 | static boolean isLeapYear(int year) 15 | { 16 | return year % 4 == 0 && year % 100 != 0 || year % 400 == 0; 17 | } 18 | 19 | int getDaysByYear(int year) 20 | { 21 | return ordinal() == 1 && isLeapYear(year) ? 29 : m_days; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /JavaAppLesson003/CreatingJarFilesViaIntelliJIDE.md: -------------------------------------------------------------------------------- 1 | ### IntelliJ vs Eclipse Proje yapısı 2 | 3 | #### Intellij'deki proje Eclipse'de workspace'e karşılık gelir. Yine IntelliJ'deki modül kavramı eclipse'de proje kavramına karşılık gelir. 4 | 5 | **IntelliJ:** _Project --> Modules_ 6 | 7 | **Eclipse:** _Workspace --> Project_ 8 | 9 | Üç şekilde jar dosyası oluşturulması gösterilecektir. İlk olarak IntelliJ IDE ile daha sonrasında Eclipse IDE ile ve en sonunda maven ile IDE'lerden bağımsız olarak jar dosyası 10 | nasıl oluşturulur anlatılacaktır. Birbirine bağlı jar dosyalarının oluşturulması ile ilgili ayrıntılar daha sonra ele alınacaktır. 11 | 12 | ### IntellJ ile Jar Dosyası Oluşturmak 13 | 14 | 1. Öncelikler Libraries adında bir Proje (Eclips'te buna workspace denir) oluşturalım. Ve bu projeyi IntelliJ,Eclipse ve Maven olarak alt dizinlere ayıralım ki daha sonraki örnekler 15 | bu dizinler altında gerçekleştirilebilsin. Library olarak JavaSampleBasic isimli projedeki util sınıflarını örnek olarak kullanacağız. 16 | 17 | ![jar1](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/Jar1.png) 18 | 19 | ![jar2](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar2.png) 20 | 21 | 2. Şimdi IntelliJ üzerinden yeni bir proje açalım ve yukarıda oluşturduğumuz dizine Libraries adında açacağımız projemizi (Eclipse de buna workspace denildiğini hatırlayınız) 22 | ekleyelim. 23 | 24 | ![jar1](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar3.png) 25 | 26 | ![jar2](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar4.png) 27 | 28 | ![jar5](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar5.png) 29 | 30 | ![jar6](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar6.png) 31 | 32 | 3. Sıra geldi Açtığımız proje içine yeni bir modüle eklemeye (Eclipse'de buna proje denilir).Şimdilik bizim Utility sınıflarını ekleyeceğiz. Modül açtıktan sonra src altına yeni 33 | paketimizi ve buna bağlı olan utility sınıflarını ekleyebiliriz. Bu sınıfları daha önce yazmış olduğumuzd JavaSampleBasic projemizden alacağız. 34 | 35 | ![jar7](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar7.png) 36 | 37 | ![jar8](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar8.png) 38 | 39 | ![jar9](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar9.png) 40 | 41 | ![jar10](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar10.png) 42 | 43 | 4. Genel olarak IntelliJ ortamında herhangi bir projenin sonucunda ortaya çıkan ürüne artifact denir. Bizim pojemiz olan _libraries_ için bu artifact jar dosyası olacaktır. Bu 44 | ürünü başka yerlere taşıyıp kullanacağız. Bunun için File --> project structure --> artifact kısmına gelip (+) kısmından jar artifact seçip from modules with dependicies seçeriz. 45 | Karşımıza modüller çıkacaktır. Ve biz Hangi modülden bir jar dosyası oluşturmak istiyorsak o modülü seçeriz. Şu an için UtilLib modülünü seçeceğiz. Ve isimlendirmeyi sanki bir 46 | paket oluşturmuş gibi verebiliriz. Ne de olsa jar dosyaları bir nevi paketlerin ziplenmiş hali gibidir. Bu işlemleri yaptıktan sınra Build -> build artifacts --> build yaparak 47 | ürünümüzü hazır hale getiririz. 48 | 49 | ![jar11](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar11.png) 50 | 51 | ![jar12](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar12.png) 52 | 53 | ![jar13](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar13.png) 54 | 55 | 5. IntelliJ ile oluşturduğumuz jar dosyalarını bir araya toplamak için Libraries --> IntelliJ --> Libraries2'nin yanına bir jar dizini açıyoruz ve artık yeni jar dosyalarını 56 | oraya ekleyebiliriz. 57 | 58 | ![jar14](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar14.png) 59 | 60 | 6. Artık jar dosyamız hazır olduğuna göre bizim util paketinden jar dosyası olarak çıktı aldığımız sınıfları silip jar dosyasını yani kütüphaneyi kullanmanın vakti geldi. Bunun 61 | için ise öncelikle proje ile jar dosyalarımız birlikte taşınabilir olsun diye JavaSampleBasic projemiz içine yeni libs dizini açıp bu proje içinde kullanmak istediğimiz kütüphane 62 | lerini buraya ekleyebiliriz. Yani sonuçta jars dosyası bütün jar dosyalarını tutar çalışmak istediğiniz proje ise o projeye ait jar dosyalarını tutar. Projeyi taşıdığınızda eğer 63 | jar dosyaları değişmemişse o proje ile birlikte jar dosyaları da taşınabilmiş olur. 64 | 65 | ![jar15](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar15.png) 66 | 67 | 7. Şimdi bu projede oluşturduğumuz kütüphaneyi kullanma işlemi kaldı. Bunun için File --> proje structure --> Libraries --> (+) --> Java --> (Kullanılacak library dizini). 68 | Bu kısımda aynı zamanda hangi modüllerin bu kütüphaneyi kullanacağını da seçmeliyiz. Şu an için tek bir modülümüz olduğu için onu seçiyoruz. 69 | 70 | ![jar16](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar16.png) 71 | 72 | 8. Sonunda kütüphanemiz kullanıma hazır olduğu için Util paketindeki sınıfları artık kütüphane üzerinden kullanabiliriz. 73 | 74 | ![jar17](https://github.com/eemustafasahin/images/blob/master/IntellJ_JarFileImages/jar17.png) 75 | 76 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/Libraries.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/MathLib/MathLib.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/Complex.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Complex sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math; 5 | 6 | import static java.lang.Math.sqrt; 7 | 8 | public class Complex { 9 | private static Complex add(double re1, double im1, double re2, double im2) 10 | { 11 | return new Complex(re1 + re2, im1 + im2); 12 | } 13 | 14 | private static Complex sub(double re1, double im1, double re2, double im2) 15 | { 16 | return add(re1, im1, -re2, -im2); 17 | } 18 | 19 | public double re, im; 20 | 21 | public Complex() 22 | {} 23 | 24 | public Complex(double re) 25 | { 26 | this.re = re; 27 | } 28 | 29 | public Complex(double re, double im) 30 | { 31 | this.re = re; 32 | this.im = im; 33 | } 34 | 35 | public Complex getConjugate() 36 | { 37 | Complex z = new Complex(); 38 | 39 | z.re = re; 40 | z.im = -im; 41 | 42 | return z; 43 | } 44 | 45 | public double getNorm() 46 | { 47 | return sqrt(re * re + im * im); 48 | } 49 | 50 | public static Complex add(double re, double im, Complex z) 51 | { 52 | return add(re, im, z.re, z.im); 53 | } 54 | 55 | public Complex add(Complex z) 56 | { 57 | return add(re, im, z.re, z.im); 58 | } 59 | 60 | public Complex add(double x, double y) 61 | { 62 | return add(re, im, x, y); 63 | } 64 | 65 | public static Complex sub(double re, double im, Complex z) 66 | { 67 | return sub(re, im, z.re, z.im); 68 | } 69 | 70 | public Complex sub(Complex z) 71 | { 72 | return sub(re, im, z.re, z.im); 73 | } 74 | 75 | public Complex sub(double x, double y) 76 | { 77 | return sub(re, im, x, y); 78 | } 79 | 80 | public String toString() 81 | { 82 | return String.format("|%.2f + i * %.2f| = %f", re, im, this.getNorm()); 83 | } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/RationalException.java: -------------------------------------------------------------------------------- 1 | package org.csystem.math; 2 | 3 | public class RationalException extends NumberFormatException { 4 | private final RationalExceptionStatus m_rationalExceptionStatus; 5 | 6 | public RationalException(String message, RationalExceptionStatus rationalExceptionStatus) 7 | { 8 | super(message); 9 | m_rationalExceptionStatus = rationalExceptionStatus; 10 | } 11 | 12 | public RationalExceptionStatus getRationalExceptionStatus() 13 | { 14 | return m_rationalExceptionStatus; 15 | } 16 | 17 | public String getMessage() 18 | { 19 | return String.format("Message:%s, Exception Status:%s", super.getMessage(), m_rationalExceptionStatus); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/RationalExceptionStatus.java: -------------------------------------------------------------------------------- 1 | package org.csystem.math; 2 | 3 | public enum RationalExceptionStatus { 4 | UNDEFINED, INDEFINITE 5 | } 6 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/geometry/AnalyticalCircle.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Analytical sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | public class AnalyticalCircle extends Circle { 7 | private Point m_center; 8 | 9 | public AnalyticalCircle() 10 | { 11 | this(0); 12 | } 13 | 14 | public AnalyticalCircle(double r) 15 | { 16 | this(r, 0, 0); 17 | } 18 | 19 | public AnalyticalCircle(Point center) 20 | { 21 | this(0, center); 22 | } 23 | 24 | public AnalyticalCircle(int x, int y) 25 | { 26 | this(0, x, y); 27 | } 28 | 29 | public AnalyticalCircle(double r, Point center) 30 | { 31 | this(r, center.x, center.y); 32 | } 33 | 34 | public AnalyticalCircle(double r, int x, int y) 35 | { 36 | super(r); 37 | m_center = new Point(x, y); 38 | } 39 | 40 | public int getX() 41 | { 42 | return m_center.x; 43 | } 44 | 45 | public void setX(int x) 46 | { 47 | m_center.x = x; 48 | } 49 | 50 | public int getY() 51 | { 52 | return m_center.y; 53 | } 54 | 55 | public void setY(int y) 56 | { 57 | m_center.y = y; 58 | } 59 | 60 | public void setCenter(Point center) 61 | { 62 | this.setCenter(center.x, center.y); 63 | } 64 | 65 | public void setCenter(int x, int y) 66 | { 67 | this.setX(x); 68 | this.setY(y); 69 | } 70 | 71 | public Point getCenter() 72 | { 73 | return new Point(m_center); 74 | } 75 | 76 | public void offset(int dx, int dy) 77 | { 78 | m_center.offset(dx, dy); 79 | } 80 | 81 | public void offset(int dxy) 82 | { 83 | this.offset(dxy, dxy); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/geometry/Circle.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Circle sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | public class Circle { 7 | private double m_r; 8 | 9 | public Circle() 10 | {} 11 | 12 | public Circle(double r) 13 | { 14 | this.setRadius(r); 15 | } 16 | 17 | public double getRadius() 18 | { 19 | return m_r; 20 | } 21 | 22 | public void setRadius(double r) 23 | { 24 | m_r = Math.abs(r); 25 | } 26 | 27 | public double getArea() 28 | { 29 | return Math.PI * m_r * m_r; 30 | } 31 | 32 | public double getCircumference() 33 | { 34 | return 2 * Math.PI * m_r; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/geometry/Point.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Point sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | import static java.lang.Math.sqrt; 7 | 8 | public class Point { 9 | public int x, y; 10 | 11 | Point(Point p) 12 | { 13 | this(p.x, p.y); 14 | } 15 | 16 | public Point() 17 | {} 18 | 19 | public Point(int x) 20 | { 21 | this(x, 0); 22 | } 23 | 24 | public Point(int x, int y) 25 | { 26 | this.x = x; 27 | this.y = y; 28 | } 29 | 30 | public double distance(Point p) 31 | { 32 | return this.distance(p.x, p.y); 33 | } 34 | 35 | public double distance(int a, int b) 36 | { 37 | return sqrt((x - a) * (x - a) + (y - b) * (y - b)); 38 | } 39 | 40 | public void offset(int dxy) 41 | { 42 | this.offset(dxy, dxy); 43 | } 44 | 45 | public void offset(int dx, int dy) 46 | { 47 | x += dx; 48 | y += dy; 49 | } 50 | 51 | public String toString() 52 | { 53 | return String.format("(%d, %d)", x, y); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/geometry/PointF.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | PointF sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | import static java.lang.Math.sqrt; 7 | 8 | public class PointF { 9 | public float x, y; 10 | 11 | PointF(PointF p) 12 | { 13 | this(p.x, p.y); 14 | } 15 | 16 | public PointF() 17 | {} 18 | 19 | public PointF(float re) 20 | { 21 | this(re, 0); 22 | } 23 | 24 | public PointF(float x, float y) 25 | { 26 | this.x = x; 27 | this.y = y; 28 | } 29 | 30 | public double distance(PointF p) 31 | { 32 | return this.distance(p.x, p.y); 33 | } 34 | 35 | public double distance(float a, float b) 36 | { 37 | return sqrt((x - a) * (x - a) + (y - b) * (y - b)); 38 | } 39 | 40 | public void offset(float dxy) 41 | { 42 | this.offset(dxy, dxy); 43 | } 44 | 45 | public void offset(float dx, float dy) 46 | { 47 | x += dx; 48 | y += dy; 49 | } 50 | 51 | public String toString() 52 | { 53 | return String.format("(%.2f, %.2f)", x, y); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/UtilLib/UtilLib.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/CommandLineUtil.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | CommandUtil sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class CommandLineUtil { 7 | private CommandLineUtil() {} 8 | 9 | private static void doWorkForControl(String msg) 10 | { 11 | Console.Error.writeLine(msg); 12 | System.exit(-1); 13 | } 14 | 15 | public static void checkForLengthEqual(String [] args, int val, String msg) 16 | { 17 | if (args.length != val) 18 | doWorkForControl(msg); 19 | } 20 | 21 | public static void checkForLengthGreater(String [] args, int val, String msg) 22 | { 23 | if (args.length <= val) 24 | doWorkForControl(msg); 25 | } 26 | 27 | public static void checkForLengthGreaterOrEqual(String [] args, int val, String msg) 28 | { 29 | if (args.length < val) 30 | doWorkForControl(msg); 31 | } 32 | 33 | public static void checkForLengthLess(String [] args, int val, String msg) 34 | { 35 | if (args.length >= val) 36 | doWorkForControl(msg); 37 | } 38 | 39 | public static void checkForLengthLessOrEqual(String [] args, int val, String msg) 40 | { 41 | if (args.length > val) 42 | doWorkForControl(msg); 43 | } 44 | 45 | public static String [] getCommandLineArgs(String [] args, String msg) 46 | { 47 | if (args.length == 0) 48 | return Console.read(msg).split("[ \t\r]+"); 49 | 50 | return args; 51 | } 52 | 53 | public static String getCommandLineArgsJoin(String [] args, String msg) 54 | { 55 | if (args.length == 0) 56 | args = Console.read(msg).split("[ \t\r]+"); 57 | 58 | return ArrayUtil.join(args, ""); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/ConsoleUtil.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | ConsoleUtil sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class ConsoleUtil { 7 | private ConsoleUtil() {} 8 | public static void putChars(int n, char ch) 9 | { 10 | for (int i = 0; i < n; ++i) 11 | System.out.print(ch); 12 | } 13 | 14 | public static void putCharsLine(int n, char ch) 15 | { 16 | putChars(n, ch); 17 | System.out.println(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/IntValue.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | IntValue sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class IntValue { 7 | private final int m_val; 8 | private static final IntValue [] MS_CACHE = new IntValue[256]; 9 | 10 | private IntValue(int val) 11 | { 12 | m_val = val; 13 | } 14 | 15 | public static final IntValue ONE = of(1); 16 | public static final IntValue ZERO = of(0); 17 | public static final IntValue TEN = of(10); 18 | 19 | public static IntValue of(int val) 20 | { 21 | if (val < -128 || val > 127) 22 | return new IntValue(val); 23 | 24 | if (MS_CACHE[val + 128] == null) //ön bellekte var mı? Yoksa nesneyi yarat 25 | MS_CACHE[val + 128] = new IntValue(val); 26 | 27 | return MS_CACHE[val + 128]; 28 | } 29 | 30 | public int getVal() 31 | { 32 | return m_val; 33 | } 34 | 35 | public int compareTo(IntValue other) 36 | { 37 | return m_val - other.m_val; 38 | } 39 | 40 | public IntValue inc() 41 | { 42 | return inc(1); 43 | } 44 | 45 | public IntValue inc(int val) 46 | { 47 | return of(m_val + val); 48 | } 49 | 50 | public String toString() 51 | { 52 | return m_val + ""; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/Pair.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Pair sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class Pair { 7 | private final F m_first; 8 | private final S m_second; 9 | 10 | public static Pair create(F first, S second) 11 | { 12 | return new Pair<>(first, second); 13 | } 14 | 15 | public Pair(F first, S second) 16 | { 17 | m_first = first; 18 | m_second = second; 19 | } 20 | 21 | public F getFirst() 22 | { 23 | return m_first; 24 | } 25 | 26 | public S getSecond() 27 | { 28 | return m_second; 29 | } 30 | 31 | //... 32 | public String toString() 33 | { 34 | return String.format("{First: %s, Second: %s}", m_first, m_second); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/StringSplitOptions.java: -------------------------------------------------------------------------------- 1 | package org.csystem.util; 2 | 3 | public enum StringSplitOptions { 4 | NONE, REMOVE_EMPTY_ENTRIES 5 | } 6 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/Triple.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Triple sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class Triple { 7 | private final F m_first; 8 | private final S m_second; 9 | private final T m_third; 10 | 11 | public static Triple create(F first, S second, T third) 12 | { 13 | return new Triple<>(first, second, third); 14 | } 15 | 16 | public Triple(F first, S second, T third) 17 | { 18 | m_first = first; 19 | m_second = second; 20 | m_third = third; 21 | } 22 | 23 | public F getFirst() 24 | { 25 | return m_first; 26 | } 27 | 28 | public S getSecond() 29 | { 30 | return m_second; 31 | } 32 | public T getThird() 33 | { 34 | return m_third; 35 | } 36 | 37 | //... 38 | public String toString() 39 | { 40 | return String.format("{First: %s, Second: %s, Third: %s}", m_first, m_second, m_third); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/Unit.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Unit sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class Unit { 7 | private final T m_t; 8 | 9 | public static Unit create(T t) 10 | { 11 | return new Unit<>(t); 12 | } 13 | public Unit(T t) 14 | { 15 | m_t = t; 16 | } 17 | 18 | public T getT() 19 | { 20 | return m_t; 21 | } 22 | 23 | public String toString() 24 | { 25 | return String.format("%s", m_t); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/Complex.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/Complex.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/Rational.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/Rational.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/RationalException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/RationalException.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/RationalExceptionStatus.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/RationalExceptionStatus.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/AnalyticalCircle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/AnalyticalCircle.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/Circle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/Circle.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/Point.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/Point.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/PointF.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/PointF.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/ArrayUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/ArrayUtil.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/CommandLineUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/CommandLineUtil.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Console$Error.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Console$Error.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Console.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Console.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/ConsoleUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/ConsoleUtil.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/IntValue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/IntValue.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/NumberUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/NumberUtil.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Pair.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Pair.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/StringSplitOptions.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/StringSplitOptions.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/StringUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/StringUtil.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Triple.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Triple.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Unit.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Unit.class -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/jars/org-csystem-math.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/jars/org-csystem-math.jar -------------------------------------------------------------------------------- /JavaAppLesson003/Libraries/IntelliJ/jars/org-csystem-util.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Libraries/IntelliJ/jars/org-csystem-util.jar -------------------------------------------------------------------------------- /JavaAppLesson003/Sample/Sample.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /JavaAppLesson003/Sample/libs/org-csystem-math.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Sample/libs/org-csystem-math.jar -------------------------------------------------------------------------------- /JavaAppLesson003/Sample/libs/org-csystem-util.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Sample/libs/org-csystem-util.jar -------------------------------------------------------------------------------- /JavaAppLesson003/Sample/out/production/Sample/org/csystem/app/App.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Sample/out/production/Sample/org/csystem/app/App.class -------------------------------------------------------------------------------- /JavaAppLesson003/Sample/out/production/Sample/org/csystem/app/GetReverseTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Sample/out/production/Sample/org/csystem/app/GetReverseTest.class -------------------------------------------------------------------------------- /JavaAppLesson003/Sample/out/production/Sample/org/csystem/samples/recurison/RecursionUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Sample/out/production/Sample/org/csystem/samples/recurison/RecursionUtil.class -------------------------------------------------------------------------------- /JavaAppLesson003/Sample/out/production/Sample/org/csystem/samples/recurison/Util.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson003/Sample/out/production/Sample/org/csystem/samples/recurison/Util.class -------------------------------------------------------------------------------- /JavaAppLesson003/Sample/src/org/csystem/app/App.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Bir yazıyı tersyüz etme yazdırma algoritmasının özyinelemeli biçimi 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.app; 5 | 6 | import org.csystem.samples.recurison.RecursionUtil; 7 | import org.csystem.util.Console; 8 | 9 | public class App { 10 | public static void main(String[] args) 11 | { 12 | GetReverseTest.run(); 13 | } 14 | } 15 | 16 | class GetReverseTest { 17 | public static void run() 18 | { 19 | for (;;) { 20 | var s = Console.read("Bir yazı giriniz:"); 21 | 22 | var revStr = RecursionUtil.getReverse(s); 23 | 24 | Console.writeLine(revStr); 25 | 26 | if (s.equals("quit")) 27 | break; 28 | } 29 | } 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /JavaAppLesson003/Sample/src/org/csystem/samples/recurison/RecursionUtil.java: -------------------------------------------------------------------------------- 1 | package org.csystem.samples.recurison; 2 | 3 | import org.csystem.util.Console; 4 | 5 | public class RecursionUtil { 6 | private static void getReverse(char [] c, int left, int right) 7 | { 8 | if (left >= right) 9 | return; 10 | 11 | char temp; 12 | 13 | temp = c[left]; 14 | c[left] = c[right]; 15 | c[right] = temp; 16 | 17 | getReverse(c, left + 1, right - 1); 18 | } 19 | 20 | private static void writeReverse(String s, int i) 21 | { 22 | if (i == s.length()) 23 | return; 24 | 25 | writeReverse(s, i + 1); 26 | Console.write(s.charAt(i)); 27 | } 28 | 29 | public static long factorial(int n) 30 | { 31 | if (n <= 0) 32 | return 1; 33 | 34 | return n * factorial(n - 1); 35 | } 36 | 37 | public static String getReverse(String s) 38 | { 39 | char [] c = s.toCharArray(); 40 | 41 | getReverse(c, 0, c.length - 1); 42 | 43 | return String.valueOf(c); 44 | } 45 | 46 | public static void writeReverse(String s) 47 | { 48 | writeReverse(s, 0); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /JavaAppLesson003/Sample/src/org/csystem/samples/recurison/Util.java: -------------------------------------------------------------------------------- 1 | package org.csystem.samples.recurison; 2 | 3 | import org.csystem.util.Console; 4 | 5 | public class Util { 6 | public static long factorial(int n) 7 | { 8 | long result = 1; 9 | 10 | for (; n > 1; --n) 11 | result *= n; 12 | 13 | return result; 14 | } 15 | 16 | public static void writeReverse(String s) 17 | { 18 | for (int i = s.length() - 1; i >= 0; --i) 19 | Console.write(s.charAt(i)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/Libraries.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/MathLib/MathLib.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/Complex.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Complex sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math; 5 | 6 | import static java.lang.Math.sqrt; 7 | 8 | public class Complex { 9 | private static Complex add(double re1, double im1, double re2, double im2) 10 | { 11 | return new Complex(re1 + re2, im1 + im2); 12 | } 13 | 14 | private static Complex sub(double re1, double im1, double re2, double im2) 15 | { 16 | return add(re1, im1, -re2, -im2); 17 | } 18 | 19 | public double re, im; 20 | 21 | public Complex() 22 | {} 23 | 24 | public Complex(double re) 25 | { 26 | this.re = re; 27 | } 28 | 29 | public Complex(double re, double im) 30 | { 31 | this.re = re; 32 | this.im = im; 33 | } 34 | 35 | public Complex getConjugate() 36 | { 37 | Complex z = new Complex(); 38 | 39 | z.re = re; 40 | z.im = -im; 41 | 42 | return z; 43 | } 44 | 45 | public double getNorm() 46 | { 47 | return sqrt(re * re + im * im); 48 | } 49 | 50 | public static Complex add(double re, double im, Complex z) 51 | { 52 | return add(re, im, z.re, z.im); 53 | } 54 | 55 | public Complex add(Complex z) 56 | { 57 | return add(re, im, z.re, z.im); 58 | } 59 | 60 | public Complex add(double x, double y) 61 | { 62 | return add(re, im, x, y); 63 | } 64 | 65 | public static Complex sub(double re, double im, Complex z) 66 | { 67 | return sub(re, im, z.re, z.im); 68 | } 69 | 70 | public Complex sub(Complex z) 71 | { 72 | return sub(re, im, z.re, z.im); 73 | } 74 | 75 | public Complex sub(double x, double y) 76 | { 77 | return sub(re, im, x, y); 78 | } 79 | 80 | public String toString() 81 | { 82 | return String.format("|%.2f + i * %.2f| = %f", re, im, this.getNorm()); 83 | } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/RationalException.java: -------------------------------------------------------------------------------- 1 | package org.csystem.math; 2 | 3 | public class RationalException extends NumberFormatException { 4 | private final RationalExceptionStatus m_rationalExceptionStatus; 5 | 6 | public RationalException(String message, RationalExceptionStatus rationalExceptionStatus) 7 | { 8 | super(message); 9 | m_rationalExceptionStatus = rationalExceptionStatus; 10 | } 11 | 12 | public RationalExceptionStatus getRationalExceptionStatus() 13 | { 14 | return m_rationalExceptionStatus; 15 | } 16 | 17 | public String getMessage() 18 | { 19 | return String.format("Message:%s, Exception Status:%s", super.getMessage(), m_rationalExceptionStatus); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/RationalExceptionStatus.java: -------------------------------------------------------------------------------- 1 | package org.csystem.math; 2 | 3 | public enum RationalExceptionStatus { 4 | UNDEFINED, INDEFINITE 5 | } 6 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/geometry/AnalyticalCircle.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Analytical sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | public class AnalyticalCircle extends Circle { 7 | private Point m_center; 8 | 9 | public AnalyticalCircle() 10 | { 11 | this(0); 12 | } 13 | 14 | public AnalyticalCircle(double r) 15 | { 16 | this(r, 0, 0); 17 | } 18 | 19 | public AnalyticalCircle(Point center) 20 | { 21 | this(0, center); 22 | } 23 | 24 | public AnalyticalCircle(int x, int y) 25 | { 26 | this(0, x, y); 27 | } 28 | 29 | public AnalyticalCircle(double r, Point center) 30 | { 31 | this(r, center.x, center.y); 32 | } 33 | 34 | public AnalyticalCircle(double r, int x, int y) 35 | { 36 | super(r); 37 | m_center = new Point(x, y); 38 | } 39 | 40 | public int getX() 41 | { 42 | return m_center.x; 43 | } 44 | 45 | public void setX(int x) 46 | { 47 | m_center.x = x; 48 | } 49 | 50 | public int getY() 51 | { 52 | return m_center.y; 53 | } 54 | 55 | public void setY(int y) 56 | { 57 | m_center.y = y; 58 | } 59 | 60 | public void setCenter(Point center) 61 | { 62 | this.setCenter(center.x, center.y); 63 | } 64 | 65 | public void setCenter(int x, int y) 66 | { 67 | this.setX(x); 68 | this.setY(y); 69 | } 70 | 71 | public Point getCenter() 72 | { 73 | return new Point(m_center); 74 | } 75 | 76 | public void offset(int dx, int dy) 77 | { 78 | m_center.offset(dx, dy); 79 | } 80 | 81 | public void offset(int dxy) 82 | { 83 | this.offset(dxy, dxy); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/geometry/Circle.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Circle sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | public class Circle { 7 | private double m_r; 8 | 9 | public Circle() 10 | {} 11 | 12 | public Circle(double r) 13 | { 14 | this.setRadius(r); 15 | } 16 | 17 | public double getRadius() 18 | { 19 | return m_r; 20 | } 21 | 22 | public void setRadius(double r) 23 | { 24 | m_r = Math.abs(r); 25 | } 26 | 27 | public double getArea() 28 | { 29 | return Math.PI * m_r * m_r; 30 | } 31 | 32 | public double getCircumference() 33 | { 34 | return 2 * Math.PI * m_r; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/geometry/Point.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Point sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | import static java.lang.Math.sqrt; 7 | 8 | public class Point { 9 | public int x, y; 10 | 11 | Point(Point p) 12 | { 13 | this(p.x, p.y); 14 | } 15 | 16 | public Point() 17 | {} 18 | 19 | public Point(int x) 20 | { 21 | this(x, 0); 22 | } 23 | 24 | public Point(int x, int y) 25 | { 26 | this.x = x; 27 | this.y = y; 28 | } 29 | 30 | public double distance(Point p) 31 | { 32 | return this.distance(p.x, p.y); 33 | } 34 | 35 | public double distance(int a, int b) 36 | { 37 | return sqrt((x - a) * (x - a) + (y - b) * (y - b)); 38 | } 39 | 40 | public void offset(int dxy) 41 | { 42 | this.offset(dxy, dxy); 43 | } 44 | 45 | public void offset(int dx, int dy) 46 | { 47 | x += dx; 48 | y += dy; 49 | } 50 | 51 | public String toString() 52 | { 53 | return String.format("(%d, %d)", x, y); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/MathLib/src/org/csystem/math/geometry/PointF.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | PointF sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.math.geometry; 5 | 6 | import static java.lang.Math.sqrt; 7 | 8 | public class PointF { 9 | public float x, y; 10 | 11 | PointF(PointF p) 12 | { 13 | this(p.x, p.y); 14 | } 15 | 16 | public PointF() 17 | {} 18 | 19 | public PointF(float re) 20 | { 21 | this(re, 0); 22 | } 23 | 24 | public PointF(float x, float y) 25 | { 26 | this.x = x; 27 | this.y = y; 28 | } 29 | 30 | public double distance(PointF p) 31 | { 32 | return this.distance(p.x, p.y); 33 | } 34 | 35 | public double distance(float a, float b) 36 | { 37 | return sqrt((x - a) * (x - a) + (y - b) * (y - b)); 38 | } 39 | 40 | public void offset(float dxy) 41 | { 42 | this.offset(dxy, dxy); 43 | } 44 | 45 | public void offset(float dx, float dy) 46 | { 47 | x += dx; 48 | y += dy; 49 | } 50 | 51 | public String toString() 52 | { 53 | return String.format("(%.2f, %.2f)", x, y); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/UtilLib/UtilLib.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/CommandLineUtil.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | CommandUtil sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class CommandLineUtil { 7 | private CommandLineUtil() {} 8 | 9 | private static void doWorkForControl(String msg) 10 | { 11 | Console.Error.writeLine(msg); 12 | System.exit(-1); 13 | } 14 | 15 | public static void checkForLengthEqual(String [] args, int val, String msg) 16 | { 17 | if (args.length != val) 18 | doWorkForControl(msg); 19 | } 20 | 21 | public static void checkForLengthGreater(String [] args, int val, String msg) 22 | { 23 | if (args.length <= val) 24 | doWorkForControl(msg); 25 | } 26 | 27 | public static void checkForLengthGreaterOrEqual(String [] args, int val, String msg) 28 | { 29 | if (args.length < val) 30 | doWorkForControl(msg); 31 | } 32 | 33 | public static void checkForLengthLess(String [] args, int val, String msg) 34 | { 35 | if (args.length >= val) 36 | doWorkForControl(msg); 37 | } 38 | 39 | public static void checkForLengthLessOrEqual(String [] args, int val, String msg) 40 | { 41 | if (args.length > val) 42 | doWorkForControl(msg); 43 | } 44 | 45 | public static String [] getCommandLineArgs(String [] args, String msg) 46 | { 47 | if (args.length == 0) 48 | return Console.read(msg).split("[ \t\r]+"); 49 | 50 | return args; 51 | } 52 | 53 | public static String getCommandLineArgsJoin(String [] args, String msg) 54 | { 55 | if (args.length == 0) 56 | args = Console.read(msg).split("[ \t\r]+"); 57 | 58 | return ArrayUtil.join(args, ""); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/ConsoleUtil.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | ConsoleUtil sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class ConsoleUtil { 7 | private ConsoleUtil() {} 8 | public static void putChars(int n, char ch) 9 | { 10 | for (int i = 0; i < n; ++i) 11 | System.out.print(ch); 12 | } 13 | 14 | public static void putCharsLine(int n, char ch) 15 | { 16 | putChars(n, ch); 17 | System.out.println(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/IntValue.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | IntValue sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class IntValue { 7 | private final int m_val; 8 | private static final IntValue [] MS_CACHE = new IntValue[256]; 9 | 10 | private IntValue(int val) 11 | { 12 | m_val = val; 13 | } 14 | 15 | public static final IntValue ONE = of(1); 16 | public static final IntValue ZERO = of(0); 17 | public static final IntValue TEN = of(10); 18 | 19 | public static IntValue of(int val) 20 | { 21 | if (val < -128 || val > 127) 22 | return new IntValue(val); 23 | 24 | if (MS_CACHE[val + 128] == null) //ön bellekte var mı? Yoksa nesneyi yarat 25 | MS_CACHE[val + 128] = new IntValue(val); 26 | 27 | return MS_CACHE[val + 128]; 28 | } 29 | 30 | public int getVal() 31 | { 32 | return m_val; 33 | } 34 | 35 | public int compareTo(IntValue other) 36 | { 37 | return m_val - other.m_val; 38 | } 39 | 40 | public IntValue inc() 41 | { 42 | return inc(1); 43 | } 44 | 45 | public IntValue inc(int val) 46 | { 47 | return of(m_val + val); 48 | } 49 | 50 | public String toString() 51 | { 52 | return m_val + ""; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/Pair.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Pair sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class Pair { 7 | private final F m_first; 8 | private final S m_second; 9 | 10 | public static Pair create(F first, S second) 11 | { 12 | return new Pair<>(first, second); 13 | } 14 | 15 | public Pair(F first, S second) 16 | { 17 | m_first = first; 18 | m_second = second; 19 | } 20 | 21 | public F getFirst() 22 | { 23 | return m_first; 24 | } 25 | 26 | public S getSecond() 27 | { 28 | return m_second; 29 | } 30 | 31 | //... 32 | public String toString() 33 | { 34 | return String.format("{First: %s, Second: %s}", m_first, m_second); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/StringSplitOptions.java: -------------------------------------------------------------------------------- 1 | package org.csystem.util; 2 | 3 | public enum StringSplitOptions { 4 | NONE, REMOVE_EMPTY_ENTRIES 5 | } 6 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/Triple.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Triple sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class Triple { 7 | private final F m_first; 8 | private final S m_second; 9 | private final T m_third; 10 | 11 | public static Triple create(F first, S second, T third) 12 | { 13 | return new Triple<>(first, second, third); 14 | } 15 | 16 | public Triple(F first, S second, T third) 17 | { 18 | m_first = first; 19 | m_second = second; 20 | m_third = third; 21 | } 22 | 23 | public F getFirst() 24 | { 25 | return m_first; 26 | } 27 | 28 | public S getSecond() 29 | { 30 | return m_second; 31 | } 32 | public T getThird() 33 | { 34 | return m_third; 35 | } 36 | 37 | //... 38 | public String toString() 39 | { 40 | return String.format("{First: %s, Second: %s, Third: %s}", m_first, m_second, m_third); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/UtilLib/src/org/csystem/util/Unit.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Unit sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public final class Unit { 7 | private final T m_t; 8 | 9 | public static Unit create(T t) 10 | { 11 | return new Unit<>(t); 12 | } 13 | public Unit(T t) 14 | { 15 | m_t = t; 16 | } 17 | 18 | public T getT() 19 | { 20 | return m_t; 21 | } 22 | 23 | public String toString() 24 | { 25 | return String.format("%s", m_t); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/Complex.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/Complex.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/Rational.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/Rational.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/RationalException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/RationalException.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/RationalExceptionStatus.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/RationalExceptionStatus.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/AnalyticalCircle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/AnalyticalCircle.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/Circle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/Circle.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/Point.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/Point.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/PointF.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/MathLib/org/csystem/math/geometry/PointF.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/ArrayUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/ArrayUtil.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/CommandLineUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/CommandLineUtil.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Console$Error.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Console$Error.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Console.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Console.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/ConsoleUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/ConsoleUtil.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/IntValue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/IntValue.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/NumberUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/NumberUtil.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Pair.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Pair.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/StringSplitOptions.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/StringSplitOptions.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/StringUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/StringUtil.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Triple.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Triple.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Unit.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/Libraries/out/production/UtilLib/org/csystem/util/Unit.class -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/jars/org-csystem-math.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/jars/org-csystem-math.jar -------------------------------------------------------------------------------- /JavaAppLesson004/Libraries/IntelliJ/jars/org-csystem-util.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Libraries/IntelliJ/jars/org-csystem-util.jar -------------------------------------------------------------------------------- /JavaAppLesson004/Sample/Sample.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /JavaAppLesson004/Sample/libs/org-csystem-math.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Sample/libs/org-csystem-math.jar -------------------------------------------------------------------------------- /JavaAppLesson004/Sample/libs/org-csystem-util.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Sample/libs/org-csystem-util.jar -------------------------------------------------------------------------------- /JavaAppLesson004/Sample/out/production/Sample/org/csystem/app/App.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Sample/out/production/Sample/org/csystem/app/App.class -------------------------------------------------------------------------------- /JavaAppLesson004/Sample/out/production/Sample/org/csystem/samples/recurison/RecursionUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Sample/out/production/Sample/org/csystem/samples/recurison/RecursionUtil.class -------------------------------------------------------------------------------- /JavaAppLesson004/Sample/out/production/Sample/org/csystem/samples/recurison/Util.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eemustafasahin/JavaEE_App_Course_Notes_and_Projects/6ea11ff4e0d08f400bd194f2be22c4f2715f17c7/JavaAppLesson004/Sample/out/production/Sample/org/csystem/samples/recurison/Util.class -------------------------------------------------------------------------------- /JavaAppLesson004/Sample/src/org/csystem/app/App.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.app; 5 | 6 | import org.csystem.util.Console; 7 | 8 | public class App { 9 | public static void main(String[] args) 10 | { 11 | int val = Console.readUInt("Bir sayı giriniz:", "Hatalı giriş yaptınız"); 12 | 13 | System.out.println(val * val); 14 | } 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /JavaAppLesson004/Sample/src/org/csystem/samples/recurison/RecursionUtil.java: -------------------------------------------------------------------------------- 1 | package org.csystem.samples.recurison; 2 | 3 | public class RecursionUtil { 4 | private static int getFibonacciNumberRecur(int n) 5 | { 6 | if (n <= 2) 7 | return n - 1; 8 | 9 | return getFibonacciNumberRecur(n - 1) + getFibonacciNumberRecur(n - 2); 10 | } 11 | 12 | private static void getReverse(char [] c, int left, int right) 13 | { 14 | if (left >= right) 15 | return; 16 | 17 | char temp; 18 | 19 | temp = c[left]; 20 | c[left] = c[right]; 21 | c[right] = temp; 22 | 23 | getReverse(c, left + 1, right - 1); 24 | } 25 | 26 | private static void writeNumberRecur(int val) 27 | { 28 | if (val / 10 != 0) 29 | writeNumber(val / 10); 30 | 31 | System.out.write((char)(val % 10 + '0')); 32 | } 33 | 34 | private static void writeNumberRecur(int val, int radix) 35 | { 36 | if (val / radix != 0) 37 | writeNumberRecur(val / radix, radix); 38 | 39 | //System.out.write((char)(val % radix >= 10 ? val % radix - 10 + 'A' : val % radix + '0')); 40 | System.out.write((char)((val % radix >= 10 ? - 10 + 'A' : '0') + val % radix)); 41 | } 42 | 43 | private static void writeReverse(String s, int i) 44 | { 45 | if (i == s.length()) 46 | return; 47 | 48 | writeReverse(s, i + 1); 49 | System.out.write(s.charAt(i)); 50 | } 51 | 52 | public static long factorial(int n) 53 | { 54 | if (n <= 0) 55 | return 1; 56 | 57 | return n * factorial(n - 1); 58 | } 59 | 60 | public static int getFibonacciNumber(int n) 61 | { 62 | if (n <= 0) 63 | return -1; 64 | 65 | return getFibonacciNumberRecur(n); 66 | } 67 | 68 | public static String getReverse(String s) 69 | { 70 | char [] c = s.toCharArray(); 71 | 72 | getReverse(c, 0, c.length - 1); 73 | 74 | return String.valueOf(c); 75 | } 76 | 77 | public static void writeNumber(int val) 78 | { 79 | if (val < 0) { 80 | System.out.write('-'); 81 | val = -val; 82 | } 83 | writeNumberRecur(val); 84 | System.out.flush(); 85 | } 86 | 87 | public static void writeNumber(int val, int radix) 88 | { 89 | if (val < 0) { 90 | System.out.write('-'); 91 | val = -val; 92 | } 93 | 94 | writeNumberRecur(val, radix); 95 | System.out.flush(); 96 | } 97 | 98 | public static void writeReverse(String s) 99 | { 100 | writeReverse(s, 0); 101 | System.out.flush(); 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /JavaAppLesson004/Sample/src/org/csystem/samples/recurison/Util.java: -------------------------------------------------------------------------------- 1 | package org.csystem.samples.recurison; 2 | 3 | public class Util { 4 | 5 | public static long factorial(int n) 6 | { 7 | long result = 1; 8 | 9 | for (; n > 1; --n) 10 | result *= n; 11 | 12 | return result; 13 | } 14 | 15 | public static int getFibonacciNumber(int n) 16 | { 17 | if (n <= 0) 18 | return -1; 19 | 20 | if (n <= 2) 21 | return n - 1; 22 | 23 | int prev1 = 0, prev2 = 1, val = 0; 24 | 25 | for (int i = 2; i < n; ++i) { 26 | val = prev1 + prev2; 27 | prev1 = prev2; 28 | prev2 = val; 29 | } 30 | 31 | return val; 32 | } 33 | 34 | public static String getReverse(String s) 35 | { 36 | return new StringBuilder(s).reverse().toString(); 37 | } 38 | 39 | public static void writeNumber(int val) 40 | { 41 | if (val == 0) { 42 | System.out.write('0'); 43 | return; 44 | } 45 | 46 | char [] s = new char[11]; 47 | int i; 48 | boolean isNegative; 49 | isNegative = false; 50 | 51 | if (val < 0) { 52 | isNegative = true; 53 | val = -val; 54 | } 55 | 56 | for (i = 0; val != 0; ++i) { 57 | s[i] = (char)(val % 10 + '0'); 58 | val /= 10; 59 | } 60 | if (isNegative) 61 | s[i++] = '-'; 62 | 63 | for (--i; i >= 0; --i) 64 | System.out.write(s[i]); 65 | 66 | System.out.flush(); 67 | } 68 | 69 | public static void writeReverse(String s) 70 | { 71 | for (int i = s.length() - 1; i >= 0; --i) 72 | System.out.write(s.charAt(i)); 73 | 74 | System.out.flush(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /JavaAppLesson005/org/csystem/app/App.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Aşağıdaki örnekte çok basit bir şifreleme algoritması yazılmıştır 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.app; 5 | 6 | import org.csystem.util.BitwiseUtil; 7 | import org.csystem.util.Console; 8 | 9 | public class App { 10 | public static void main(String[] args) 11 | { 12 | BitwiseUtil.writeBits((int)'a'); 13 | BitwiseUtil.writeBits(3); 14 | BitwiseUtil.writeBits('a' ^ 3); 15 | Console.writeLine('a' ^ 3); 16 | Console.writeLine((char)('a' ^ 3)); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /JavaAppLesson005/org/csystem/samples/recurison/RecursionUtil.java: -------------------------------------------------------------------------------- 1 | package org.csystem.samples.recurison; 2 | 3 | public class RecursionUtil { 4 | private static int getFibonacciNumberRecur(int n) 5 | { 6 | if (n <= 2) 7 | return n - 1; 8 | 9 | return getFibonacciNumberRecur(n - 1) + getFibonacciNumberRecur(n - 2); 10 | } 11 | 12 | private static void getReverse(char [] c, int left, int right) 13 | { 14 | if (left >= right) 15 | return; 16 | 17 | char temp; 18 | 19 | temp = c[left]; 20 | c[left] = c[right]; 21 | c[right] = temp; 22 | 23 | getReverse(c, left + 1, right - 1); 24 | } 25 | 26 | private static void writeNumberRecur(int val) 27 | { 28 | if (val / 10 != 0) 29 | writeNumber(val / 10); 30 | 31 | System.out.write((char)(val % 10 + '0')); 32 | } 33 | 34 | private static void writeNumberRecur(int val, int radix) 35 | { 36 | if (val / radix != 0) 37 | writeNumberRecur(val / radix, radix); 38 | 39 | //System.out.write((char)(val % radix >= 10 ? val % radix - 10 + 'A' : val % radix + '0')); 40 | System.out.write((char)((val % radix >= 10 ? - 10 + 'A' : '0') + val % radix)); 41 | } 42 | 43 | private static void writeReverse(String s, int i) 44 | { 45 | if (i == s.length()) 46 | return; 47 | 48 | writeReverse(s, i + 1); 49 | System.out.write(s.charAt(i)); 50 | } 51 | 52 | public static long factorial(int n) 53 | { 54 | if (n <= 0) 55 | return 1; 56 | 57 | return n * factorial(n - 1); 58 | } 59 | 60 | public static int getFibonacciNumber(int n) 61 | { 62 | if (n <= 0) 63 | return -1; 64 | 65 | return getFibonacciNumberRecur(n); 66 | } 67 | 68 | public static String getReverse(String s) 69 | { 70 | char [] c = s.toCharArray(); 71 | 72 | getReverse(c, 0, c.length - 1); 73 | 74 | return String.valueOf(c); 75 | } 76 | 77 | public static void writeNumber(int val) 78 | { 79 | if (val < 0) { 80 | System.out.write('-'); 81 | val = -val; 82 | } 83 | writeNumberRecur(val); 84 | System.out.flush(); 85 | } 86 | 87 | public static void writeNumber(int val, int radix) 88 | { 89 | if (val < 0) { 90 | System.out.write('-'); 91 | val = -val; 92 | } 93 | 94 | writeNumberRecur(val, radix); 95 | System.out.flush(); 96 | } 97 | 98 | public static void writeReverse(String s) 99 | { 100 | writeReverse(s, 0); 101 | System.out.flush(); 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /JavaAppLesson005/org/csystem/samples/recurison/Util.java: -------------------------------------------------------------------------------- 1 | package org.csystem.samples.recurison; 2 | 3 | public class Util { 4 | 5 | public static long factorial(int n) 6 | { 7 | long result = 1; 8 | 9 | for (; n > 1; --n) 10 | result *= n; 11 | 12 | return result; 13 | } 14 | 15 | public static int getFibonacciNumber(int n) 16 | { 17 | if (n <= 0) 18 | return -1; 19 | 20 | if (n <= 2) 21 | return n - 1; 22 | 23 | int prev1 = 0, prev2 = 1, val = 0; 24 | 25 | for (int i = 2; i < n; ++i) { 26 | val = prev1 + prev2; 27 | prev1 = prev2; 28 | prev2 = val; 29 | } 30 | 31 | return val; 32 | } 33 | 34 | public static String getReverse(String s) 35 | { 36 | return new StringBuilder(s).reverse().toString(); 37 | } 38 | 39 | public static void writeNumber(int val) 40 | { 41 | if (val == 0) { 42 | System.out.write('0'); 43 | return; 44 | } 45 | 46 | char [] s = new char[11]; 47 | int i; 48 | boolean isNegative; 49 | isNegative = false; 50 | 51 | if (val < 0) { 52 | isNegative = true; 53 | val = -val; 54 | } 55 | 56 | for (i = 0; val != 0; ++i) { 57 | s[i] = (char)(val % 10 + '0'); 58 | val /= 10; 59 | } 60 | if (isNegative) 61 | s[i++] = '-'; 62 | 63 | for (--i; i >= 0; --i) 64 | System.out.write(s[i]); 65 | 66 | System.out.flush(); 67 | } 68 | 69 | public static void writeReverse(String s) 70 | { 71 | for (int i = s.length() - 1; i >= 0; --i) 72 | System.out.write(s.charAt(i)); 73 | 74 | System.out.flush(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /JavaAppLesson005/org/csystem/util/BitwiseUtil.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | BitwiseUtil sınıfı 3 | ----------------------------------------------------------------------------------------------------------------------*/ 4 | package org.csystem.util; 5 | 6 | public class BitwiseUtil { 7 | private BitwiseUtil() 8 | {} 9 | 10 | private static void writeBits(String bitsStr, int bitsLength) 11 | { 12 | int lengthZeros = bitsLength - bitsStr.length(); 13 | 14 | Console.writeLine(lengthZeros != 0 ? String.format("%0" + lengthZeros + "d%s", 0, bitsStr) : bitsStr); 15 | } 16 | 17 | public static void writeBits(char val) 18 | { 19 | writeBits(Integer.toBinaryString(val), 16); 20 | } 21 | 22 | public static void writeBits(byte val) 23 | { 24 | writeBits(Integer.toBinaryString(val), 8); 25 | } 26 | 27 | public static void writeBits(short val) 28 | { 29 | writeBits(Integer.toBinaryString(val), 16); 30 | } 31 | 32 | public static void writeBits(int val) 33 | { 34 | writeBits(Integer.toBinaryString(val), 32); 35 | } 36 | 37 | public static void writeBits(long val) 38 | { 39 | writeBits(Long.toBinaryString(val), 64); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /JavaAppLesson006/org/csystem/app/App.java: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------------------------------------------------- 2 | Sınıf Çalışması: Klavyeden alınan gün, ay ve yıl bilgilerine göre kişinin doğum günü geçmişse 3 | "geçmiş doğum gününü kutlu olsun", o an doğum günü ise "doğum gününüz kutlu olsun", doğum henüz gelmemişse 4 | "doğum gününüz şimdiden kutlu olsun" mesajlarından birini ekrana basan programı Calendar sınıfını kullanarak yazınız 5 | ----------------------------------------------------------------------------------------------------------------------*/ 6 | package org.csystem.app; 7 | 8 | import org.csystem.util.Console; 9 | 10 | import java.util.Calendar; 11 | 12 | class App { 13 | public static void main(String[] args) 14 | { 15 | Calendar now = Calendar.getInstance(); 16 | 17 | Console.writeLine("%02d/%02d/%04d %02d:%02d:%02d.%03d", 18 | now.get(Calendar.DAY_OF_MONTH), 19 | now.get(Calendar.MONTH) + 1, 20 | now.get(Calendar.YEAR), 21 | now.get(Calendar.HOUR_OF_DAY), 22 | now.get(Calendar.MINUTE), 23 | now.get(Calendar.SECOND), 24 | now.get(Calendar.MILLISECOND)); 25 | 26 | now.set(Calendar.HOUR_OF_DAY, 10); 27 | 28 | Console.writeLine("%02d/%02d/%04d %02d:%02d:%02d.%03d", 29 | now.get(Calendar.DAY_OF_MONTH), 30 | now.get(Calendar.MONTH) + 1, 31 | now.get(Calendar.YEAR), 32 | now.get(Calendar.HOUR_OF_DAY), 33 | now.get(Calendar.MINUTE), 34 | now.get(Calendar.SECOND), 35 | now.get(Calendar.MILLISECOND)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /JavaAppLesson006/org/csystem/samples/recurison/RecursionUtil.java: -------------------------------------------------------------------------------- 1 | package org.csystem.samples.recurison; 2 | 3 | public class RecursionUtil { 4 | private static int getFibonacciNumberRecur(int n) 5 | { 6 | if (n <= 2) 7 | return n - 1; 8 | 9 | return getFibonacciNumberRecur(n - 1) + getFibonacciNumberRecur(n - 2); 10 | } 11 | 12 | private static void getReverse(char [] c, int left, int right) 13 | { 14 | if (left >= right) 15 | return; 16 | 17 | char temp; 18 | 19 | temp = c[left]; 20 | c[left] = c[right]; 21 | c[right] = temp; 22 | 23 | getReverse(c, left + 1, right - 1); 24 | } 25 | 26 | private static void writeNumberRecur(int val) 27 | { 28 | if (val / 10 != 0) 29 | writeNumber(val / 10); 30 | 31 | System.out.write((char)(val % 10 + '0')); 32 | } 33 | 34 | private static void writeNumberRecur(int val, int radix) 35 | { 36 | if (val / radix != 0) 37 | writeNumberRecur(val / radix, radix); 38 | 39 | //System.out.write((char)(val % radix >= 10 ? val % radix - 10 + 'A' : val % radix + '0')); 40 | System.out.write((char)((val % radix >= 10 ? - 10 + 'A' : '0') + val % radix)); 41 | } 42 | 43 | private static void writeReverse(String s, int i) 44 | { 45 | if (i == s.length()) 46 | return; 47 | 48 | writeReverse(s, i + 1); 49 | System.out.write(s.charAt(i)); 50 | } 51 | 52 | public static long factorial(int n) 53 | { 54 | if (n <= 0) 55 | return 1; 56 | 57 | return n * factorial(n - 1); 58 | } 59 | 60 | public static int getFibonacciNumber(int n) 61 | { 62 | if (n <= 0) 63 | return -1; 64 | 65 | return getFibonacciNumberRecur(n); 66 | } 67 | 68 | public static String getReverse(String s) 69 | { 70 | char [] c = s.toCharArray(); 71 | 72 | getReverse(c, 0, c.length - 1); 73 | 74 | return String.valueOf(c); 75 | } 76 | 77 | public static void writeNumber(int val) 78 | { 79 | if (val < 0) { 80 | System.out.write('-'); 81 | val = -val; 82 | } 83 | writeNumberRecur(val); 84 | System.out.flush(); 85 | } 86 | 87 | public static void writeNumber(int val, int radix) 88 | { 89 | if (val < 0) { 90 | System.out.write('-'); 91 | val = -val; 92 | } 93 | 94 | writeNumberRecur(val, radix); 95 | System.out.flush(); 96 | } 97 | 98 | public static void writeReverse(String s) 99 | { 100 | writeReverse(s, 0); 101 | System.out.flush(); 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /JavaAppLesson006/org/csystem/samples/recurison/Util.java: -------------------------------------------------------------------------------- 1 | package org.csystem.samples.recurison; 2 | 3 | public class Util { 4 | 5 | public static long factorial(int n) 6 | { 7 | long result = 1; 8 | 9 | for (; n > 1; --n) 10 | result *= n; 11 | 12 | return result; 13 | } 14 | 15 | public static int getFibonacciNumber(int n) 16 | { 17 | if (n <= 0) 18 | return -1; 19 | 20 | if (n <= 2) 21 | return n - 1; 22 | 23 | int prev1 = 0, prev2 = 1, val = 0; 24 | 25 | for (int i = 2; i < n; ++i) { 26 | val = prev1 + prev2; 27 | prev1 = prev2; 28 | prev2 = val; 29 | } 30 | 31 | return val; 32 | } 33 | 34 | public static String getReverse(String s) 35 | { 36 | return new StringBuilder(s).reverse().toString(); 37 | } 38 | 39 | public static void writeNumber(int val) 40 | { 41 | if (val == 0) { 42 | System.out.write('0'); 43 | return; 44 | } 45 | 46 | char [] s = new char[11]; 47 | int i; 48 | boolean isNegative; 49 | isNegative = false; 50 | 51 | if (val < 0) { 52 | isNegative = true; 53 | val = -val; 54 | } 55 | 56 | for (i = 0; val != 0; ++i) { 57 | s[i] = (char)(val % 10 + '0'); 58 | val /= 10; 59 | } 60 | if (isNegative) 61 | s[i++] = '-'; 62 | 63 | for (--i; i >= 0; --i) 64 | System.out.write(s[i]); 65 | 66 | System.out.flush(); 67 | } 68 | 69 | public static void writeReverse(String s) 70 | { 71 | for (int i = s.length() - 1; i >= 0; --i) 72 | System.out.write(s.charAt(i)); 73 | 74 | System.out.flush(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JavaEE_App_Course_Notes_and_Projects 2 | These course notes contain additional informations on core java and have some JavaEE projects. 3 | --------------------------------------------------------------------------------