This repository was archived by the owner on Apr 20, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathcode
More file actions
114 lines (104 loc) · 2.6 KB
/
Copy pathcode
File metadata and controls
114 lines (104 loc) · 2.6 KB
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
/**
* Lovability
*
* @author (Gio, Ilyas, Ben)
* @version (1.0)
*/
import java.util.Random;
import java.lang.Math;
public class Lovability2
{
public String s1;
public String s2;
//compare method variables
public int cpr = 0;
public int random = 0;
//length method variables
public int rslt = 0;
public int i1 = 0;
public int i2 = 0;
public char c1 = 'a';
public char c2 = 'a';
//index method variables
public int ind1 = 0;
public int ind2 = 0;
public int indTot = 0;
public char x1 = 'o';
public char x2 = 'o';
//check method variable
boolean ck;
public int[] intArray = new int[3];
public Random rand = new Random();
public Lovability2(String string1, String string2)
{
s1 = string1;
s2 = string2;
}
public String getS()
{
return s1 + s2;
}
public int compareNr(){
intArray[0] = 0;
cpr = s1.compareTo(s2);
random = rand.nextInt(10) + 1;
cpr = cpr * random;
intArray[0] = Math.abs(cpr);
return intArray[0];
}
public int compareLgt(){
intArray[1] = 0;
rslt = 0;
c1 = 'a';
i1 = 0;
c2 = 'a';
i2 = 0;
random = rand.nextInt(2) + 1;
if(s1.length() >= s2.length()){
s1 = s1.toUpperCase();
s1 = s1.substring(0, 1);
c1 = s1.charAt(0);
i1 = (int) c1;
s2 = s2.toLowerCase();
s2 = s2.substring(0, 1);
c2 = s2.charAt(0);
i2 = (int) c2;
rslt = i2 - i1;
}else{
s1 = s1.toLowerCase();
s1 = s1.substring(0, 1);
c1 = s1.charAt(0);
i1 = (int) c1;
s2 = s2.toUpperCase();
s2 = s2.substring(0, 1);
c2 = s2.charAt(0);
i2 = (int) c2;
rslt = i1 - i2;
}
rslt = rslt * random;
intArray[1] = Math.abs(rslt);
return intArray[1];
}
public int compareIndx(){
intArray[2] = 0;
x1 = 'o';
x2 = 'o';
ind1 = 0;
ind2 = 0;
random = rand.nextInt(30) + 15;
ind1 = s1.indexOf(x1);
ind2 = s2.indexOf(x2);
indTot = ind1 + ind2;
indTot = indTot * random;
intArray[2] = Math.abs(indTot);
return intArray[2];
}
public boolean check(){
ck = s1.equals(s2);
return ck;
}
public void printPerc(){
random = rand.nextInt(2);
System.out.println("Your percentage is: " + intArray[random] + "%.");
}
}