Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 688c8be

Browse files
Add files via upload
1 parent 12af18d commit 688c8be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4140
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /