-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
com.lifewriter.fileworkeractions.defined.xml
334 lines (276 loc) · 8.76 KB
/
com.lifewriter.fileworkeractions.defined.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<?xml version="1.0" encoding="utf-8"?>
xml
Android private class span xml encoding
//android.permission.UI.utiliies.ALLOW_CREATE_UTILITIES.java
//android.permission.UI.ALLOW_CREATE_FILE_WORKER.java
//com.lifewriter.fileworker.actions.defined
onstart(create worker to perform file requests and functions using file worker actions defined as scripts"worker can(action defined list is this files script list)")
SCRIPT LIST
//Hello World/worker csn speak
class HelloWorld
{
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
//worker can configure input output number
//import java.util.Scanner;
class InputOutputNumber {
public static void main(String[] args) {
/* This reads the input provided by user
* using keyboard
*/
Scanner scan = new Scanner(System.in);
System.out.print("Enter any number: ");
// This method reads the number provided using keyboard
int num = scan.nextInt();
// Closing Scanner after the use
scan.close();
// Displaying the number
System.out.println("\n\nThe number entered by user: "+num);
}
}
//fibonacci numbers
class Fibonacci {
static int n1=0,n2=1,n3=0;
static void printFibonacci(int count){
if(count>0){
n3 = n1 + n2;
n1 = n2;
n2 = n3;
System.out.print(" "+n3);
printFibonacci(count-1);
}
}
public static void main(String args[]){
int count=20;
System.out.print(n1+" "+n2);
printFibonacci(count-2);
}
}
//worker can do math multiplication tables
//import java.util.Scanner;
class MultiplicationTable{
public static void main(String args[]){
/* This reads the input provided by user
* using keyboard
*/
Scanner scan = new Scanner(System.in);
System.out.print("Enter a positive integer: ");
// This method reads the number provided using keyboard
int num = scan.nextInt();
System.out.print("\nLength of the table: ");
int lt = scan.nextInt();
// Closing Scanner after the use
scan.close();
System.out.println("\n\n*****MULTIPLICATION TABLE*****\n");
for(int j=1;j<=lt;j++){
System.out.print(" "+num*j+" ");
}
System.out.print("\n");
}
} worker can enhance for loop
class EnhancedFor
{
public static void main(String[] args)
{ int[] list ={1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int sum = sumListEnhanced(list);
System.out.println("Sum of elements in list: " + sum);
System.out.println("Original List");
printList(list);
System.out.println("Calling addOne");
addOne(list);
System.out.println("List after call to addOne");
printList(list);
System.out.println("Calling addOneError");
addOneError(list);
System.out.println("List after call to addOneError. Note elements of list did not change.");
printList(list);
}
// pre: list != null
// post: return sum of elements
// uses enhanced for loop
public static int sumListEnhanced(int[] list)
{ int total = 0;
for(int val : list)
{ total += val;
}
return total;
}
// pre: list != null
// post: return sum of elements
// use traditional for loop
public static int sumListOld(int[] list)
{ int total = 0;
for(int i = 0; i < list.length; i++)
{ total += list[i];
System.out.println( list[i] );
}
return total;
}
// pre: list != null
// post: none.
// The code appears to add one to every element in the list, but does not
public static void addOneError(int[] list)
{ for(int val : list)
{ val = val + 1;
}
}
// pre: list != null
// post: adds one to every element of list
public static void addOne(int[] list)
{ for(int i = 0; i < list.length; i++)
{ list[i]++;
}
}
public static void printList(int[] list)
{ System.out.println("index, value");
for(int i = 0; i < list.length; i++)
{ System.out.println(i + ", " + list[i]);
}
}
}
//worker can figure factorial of a nember
import java.util.Scanner;
class FactorialNumber {
public static void main(String[] args) {
int number;
System.out.println("Enter the number: ");
Scanner scanner = new Scanner(System.in);
number = scanner.nextInt();
scanner.close();
long fact = 1;
int i = 1;
while(i<=number)
{
fact = fact * i;
i++;
}
System.out.println("Factorial of "+number+" is: "+fact);
}
//worker can perform palindrome check}
import java.util.Scanner;
class PalindromeCheck
{
public static boolean isPal(String s)
{ // if length is 0 or 1 then String is palindrome
if(s.length() == 0 || s.length() == 1)
return true;
if(s.charAt(0) == s.charAt(s.length()-1))
/* check for first and last char of String:
* if they are same then do the same thing for a substring
* with first and last char removed. and carry on this
* until you string completes or condition fails
* Function calling itself: Recursion
*/
return isPal(s.substring(1, s.length()-1));
/* If program control reaches to this statement it means
* the String is not palindrome hence return false.
*/
return false;
}
public static void main(String[]args)
{
//For capturing user input
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the String for check:");
String string = scanner.nextLine();
/* If function returns true then the string is
* palindrome else not
*/
if(isPal(string))
System.out.println(string + " is a palindrome");
else
System.out.println(string + " is not a palindrome");
}
}
worker can do simple math
import java.util.Scanner;
class SimpleCalculator {
public static void main(String[] args) {
double num1, num2;
Scanner scanner = new Scanner(System.in);
System.out.print("Enter first number:");
/* We are using data type double so that user
* can enter integer as well as floating point
* value
*/
num1 = scanner.nextDouble();
System.out.print("Enter second number:");
num2 = scanner.nextDouble();
System.out.print("Enter an operator (+, -, *, /): ");
char operator = scanner.next().charAt(0);
scanner.close();
double output;
switch(operator)
{
case '+':
output = num1 + num2;
break;
case '-':
output = num1 - num2;
break;
case '*':
output = num1 * num2;
break;
case '/':
output = num1 / num2;
break;
/* If user enters any other operator or char apart from
* +, -, * and /, then display an error message to user
*
*/
default:
System.out.printf("You have entered wrong operator");
return;
}
System.out.println("\n\n"+num1+" "+operator+" "+num2+": "+output);
}
}//worker can calculate floyds triangle
import java.util.Scanner;
class FloydTriangle {
public static void main(String args[])
{
int rows, number = 1, counter, j;
Scanner input = new Scanner(System.in);
System.out.println("Enter the number of rows for floyd's triangle:");
rows = input.nextInt();
System.out.println("\n\nFloyd's triangle");
System.out.println("****************");
for ( counter = 1 ; counter <= rows ; counter++ )
{
for ( j = 1 ; j <= counter ; j++ )
{
System.out.print(number+" ");
//Incrementing the number value
number++;
}
//For new line
System.out.println();
}
}
}
//worker can calculate linear eqations
import java.util.Scanner;
class FloydTriangle {
public static void main(String args[])
{
int rows, number = 1, counter, j;
Scanner input = new Scanner(System.in);
System.out.println("Enter the number of rows for floyd's triangle:");
rows = input.nextInt();
System.out.println("\n\nFloyd's triangle");
System.out.println("****************");
for ( counter = 1 ; counter <= rows ; counter++ )
{
for ( j = 1 ; j <= counter ; j++ )
{
System.out.print(number+" ");
//Incrementing the number value
number++;
}
//For new line
System.out.println();
}
}
}