SlideShare a Scribd company logo
1 of 10
Download to read offline
============================String_Test=========================
package com.String_Function;
public class String_Fucntion {
// Ok
// test function is used to test the function input in ok and xx form
public final static void test(String get , String expected){
try {
// condition used for result
if (get.equalsIgnoreCase(expected)){
System.out.print("OK"+" ");
}// condition used for reject the result
else{
System.out.print("XX"+" ");
}
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("System not working ");;
}
}
//Ok
// donuts and send back to the main for test
public final static String donuts(int count){
try {
// Condition for donuts
if(count == 10 || count > 10){
// if the count is equal the 10 and grater than the 10
return "Number of donuts: many";
}else{
// if the count is less than the 10 than print
return "Number of donuts: "+count;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
//Ok
// both_ends and send back to the main for test
public final static String both_ends(String string){
//
try {
// if the length of the String is one
if(string.length() <= 1 || string.isEmpty()){
return "";
}else{
// this return back the both_end String
return string.substring(0,2)+""+ new StringBuffer(new
StringBuffer(string).reverse().substring(0, 2)).reverse();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
//Ok
// fix_start and send back to the main for test
public final static String fix_start(String string){
//
//
try {
//
if(string.isEmpty()){
return null;
}
// get the temp as String to get the string who value is less than one
the real string
String temp = string.substring(1);
// return the real fix_start String to the test
return string.charAt(0)+temp.replaceAll(string.charAt(0)+"", "*");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
// Ok
// mix and send back to the main for test
public final static String mixUp(String string, String string2){
try {
// return the mix string and test it
return string.replace(string.subSequence(0, 2), string2.subSequence(0,
2))+" "+string2.replace(string2.subSequence(0, 2), string.subSequence(0, 2));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
//Ok
// verbing and send back to the main for test
public final static String verbing(String string){
//
try {
// if the length of the String is less than 3 than not change the
string and send same back
if(string.length() < 3){
// send the same string that i received for the parameter
return string;
}else{
// if the string is ing than return back the same
if(string.contains("ing") && string.length() == 3){
// this one used when it containing the ing in the text
return string;
}else if(string.contains("ing")){
// if true than concat the old string with ly
return string+"ly";
}else{
// if flase than concat the onl string with ing
return string+"ing";
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
// Ok
// not bad and send back to the main for test
public final static String not_bad(String string){
//
try {
// condition for not and bad contains in the string
if(string.contains("not") && string.contains("bad")){
// if yes than watch not is first come and bad is lass
if(string.indexOf("not") < string.indexOf("bad")){
// return back to the main
return
string.replace(string.substring(string.indexOf("not")), "good");
// if the bad is first and not is lass than is will work
}else if(string.indexOf("not") > string.indexOf("bad")){
// than send the same string that get from the parameter
// send the same the string
return string;
}
}else{
// send the same the sting
// if only not and only bad contains in the string
return string;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
return null;
}
//Ok
// front back and send back to the main for test
public final static String front_back(String string , String string2){
// condition for both equal length
if(string.length()%2 == 0 && string2.length()%2 == 0){
// send back to the main
return string.substring(0,
string.length()/2)+string2.substring(0,string2.length()/2)+string.substring(string.length(
)/2)+string2.substring(string2.length()/2);
}else{
// condition for first even and second odd
if(string.length()%2 == 0 && string2.length()%2 == 1){
// send back to the mian
return string.substring(0,
string.length()/2)+string2.substring(0,string2.length()/2+1)+string.substring(string.lengt
h()/2)+string2.substring(string2.length()/2+1);
}else{
// this one work when both string are odd
// send back to the main
return string.substring(0,
string.length()/2+1)+string2.substring(0,string2.length()/2+1)+string.substring(string.len
gth()/2+1)+string2.substring(string2.length()/2+1);
}
}
}
//
//
public static void main(String args[]){
//
System.out.println ("donuts");
// Each line calls donuts, compares its result to the expected for that call.
test(donuts(4), "Number of donuts: 4");
test(donuts(9), "Number of donuts: 9");
test(donuts(10), "Number of donuts: many");
test(donuts(99), "Number of donuts: many");
//-----------------------------------------
// Each line calls both_end, compares its result to the expected for that
call.
System.out.println("nboth_ends");
test(both_ends("spring"), "spng");
test(both_ends("Hello"), "Helo");
test(both_ends("a"), "");
test(both_ends("xyz"), "xyyz");
//-----------------------------------------
//Each line calls fix_start, compares its result to the expected for that
call.
System.out.println("nfix_start");
test(fix_start("babble"), "ba**le");
test(fix_start("aardvark"), "a*rdv*rk");
test(fix_start("google"), "goo*le");
test(fix_start("donut"), "donut");
//----------------------------------------
//Each line calls mixUp, compares its result to the expected for that call.
System.out.println("nmix_up");
test(mixUp("mix", "pod"), "pox mid");
test(mixUp("dog", "dinner"), "dig donner");
test(mixUp("gnash", "sport"), "spash gnort");
test(mixUp("pezzy", "firm"), "fizzy perm");
//---------------------------------------
//Each line calls verbing, compares its result to the expected for that call.
System.out.println("nverbing");
test(verbing("hail"), "hailing");
test(verbing("swiming"), "swimingly");
test(verbing("do"), "do");
test(verbing("ing"),"ing");
//--------------------------------------
//Each line calls not_bad, compares its result to the expected for that call.
System.out.println("nnot_bad");
test(not_bad("This movie is not so bad"), "This movie is good");
test(not_bad("This dinner is not that bad!"), "This dinner is good");
test(not_bad("This tea is not hot"), "This tea is not hot");
test(not_bad("It's bad yet not"), "It's bad yet not");
//-------------------------------------
//Each line calls front_back, compares its result to the expected for that
call.
System.out.println("nfront_back");
test(front_back("abcd", "xy"), "abxcdy");
test(front_back("abcde", "xyz"), "abcxydez");
test(front_back("Kitten", "Donut"), "KitDontenut");
}
}
=============================== ListTest ====================================
package com.String_Function;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
//
public class List_Reddal {
//Ok
// test the both String and List
public final static void test(Object get , Object expected){
try {
// condition used for result
if (get.toString().equalsIgnoreCase(expected.toString())){
System.out.print("OK"+" ");
}// condition used for reject the result
else{
System.out.print("XX"+" ");
}
} catch (Exception e) {
//
System.out.println("System not working ");;
}
}
// Ok
// test the match ends and send back to the main
public final static Object match_ends(Object match_e[]){
try {
// count the word
int count_end = 0;
// get the single word
Object get_word;
// break the word into the single char but the type is Object
Object temp = null,temp2 = null;
// used the loop to access the array index
for(Object match_key : match_e){
// assign the word to the single object
get_word = match_key.toString();
// condition for null or empty String
if(!get_word.equals("")){
// get the first single letter but the type is Object
temp = get_word.toString().charAt(0);
// get the last single letter but the type is Object
temp2 = get_word.toString().charAt(get_word.toString().length()-1);
// condition for both first and end are equal if true it count else not
if(temp.toString().equalsIgnoreCase(temp2.toString())){
count_end += 1;
}
}
}
// return the Result of the Process
return count_end;
// catch used to handle the exception
} catch (Exception e) {
// if the exception is rise it show the message of the error
return "Indext out of Range The Error are found in method match_End";
}
}
// Ok
// test the front_x and send back to the main
public final static Object front_x(Object f_x[]){
// get the two array
// array with_x
ArrayList<Object> array_with_xs = new ArrayList<Object>();
// array with_out x
ArrayList<Object> array_without_xs = new ArrayList<Object>();
// loop for adding the item individual
for (Object object : f_x) {
// condition for front_X
if((object.toString().charAt(0) == 'x') || (object.toString().charAt(0) == 'X')){
// add the front_x
array_with_xs.add(object);
}else{
// add the non_Front_x
array_without_xs.add(object);
}
}
// sort the both the array
Collections.sort(array_with_xs,null);
//
Collections.sort(array_without_xs,null);
//
// know Combine the both array,s into the array_with_xs
for (Object object : array_without_xs ) {
array_with_xs.add(object);
}
// send array for test
return array_with_xs.toString();
}
// Ok
// test the sort_last and send back to the main
public final static Object sort_last(Object array_sort_last_1[][]){
// Method work only Integer
// get the temp array for single index change
Object temp1[];
// loop's work like a sort-ing
// outer-loop
for(int i = 0; i < array_sort_last_1.length-1; i++) {
// inner-loop
for (int j = i+1; j < array_sort_last_1.length; j++) {
// condition watch
// (Integer) casting required to convert the object element into the Integer
if(((Integer) array_sort_last_1[i][array_sort_last_1[i].length-1] > (Integer)
array_sort_last_1[j][array_sort_last_1[j].length-1])){
// sewap_ing apply_ing on the address of the array not on item
temp1 = array_sort_last_1[i];
array_sort_last_1[i] = array_sort_last_1[j];
array_sort_last_1[j] = temp1;
}
}
}
// send array for test
return Arrays.deepToString(array_sort_last_1);
}
// Ok
// test the remove_adjacent and send back to the main
public final static Object remove_adjacent(Object r_adjacent[]){
// get the temp array and pass the all element
// of the first array into the temp
ArrayList<Object> temp_Array = new ArrayList<Object>();
// loop used to get the single item at one time
for (Object object : r_adjacent) {
// if it contains the object into the array it
//become false and not item more add to the temp
if(!(temp_Array.contains(object))){
// add teh single object to the temp_Array
temp_Array.add(object);
}
}
// return the array as the type of string
return temp_Array.toString();
}
// Ok
// test the linear_merge and send back to the main
public final static Object linear_merge(Object list1[], Object list2[]){
//
// merge mean combine to list into single list
ArrayList<Object> object = new ArrayList<Object>();
// add the first list
for (Object object1 : list1) {
// condition for front_X
object.add(object1);
}
// add the second list
for (Object object2 : list2) {
// condition for front_X
object.add(object2);
}
// sort the list by use of the Collection
Collections.sort(object,null);
return object.toString();
}
//
// Main Method
public static void main(String[] args) {
//Ok
// Match_end problem
System.out.println("Match_End");
// array 1 match_ends
Object array[] = {"xxa",121, "aa", "x", "bbb"};
test(match_ends(array), 4);
// array 2 match_ends
Object array1[] = {"", "xyw", "xy", "xyx", "xx"};
test(match_ends(array1), 2);
// array 3 match_ends
Object array2[] = {"aaA", "be", "abc", "hello"};
test(match_ends(array2), 1);
//-------------------------------------------------
// Ok
// Sort problem
System.out.println("nSort_last");
// array,s 1 sort_last
Object array_sort_last_1[][] = { {1, 3}, {3, 2}, {2, 1}};
Object array_sort_last_1_1[][] = { {2, 1}, {3, 2}, {1, 3}};
test(sort_last(array_sort_last_1), Arrays.deepToString(array_sort_last_1_1));
// array,s 2 sort_last
Object array_sort_last_2[][] = {{2, 3},{1, 2},{3, 1}};
Object array_sort_last_2_2[][] = {{3, 1}, {1, 2}, {2, 3}};
test(sort_last(array_sort_last_2), Arrays.deepToString(array_sort_last_2_2));
// array,s 3 sort_last
Object array_sort_last_3[][] = {{1, 7}, {1, 3}, {3, 4, 5}, {2, 2}};
Object array_sort_last_3_3[][] = {{2, 2}, {1, 3}, {3, 4, 5}, {1, 7}};
test(sort_last(array_sort_last_3), Arrays.deepToString(array_sort_last_3_3));
//-------------------------------------------------
// Ok
// Front_end problem
System.out.println("nFront_X");
// array,s 1 front-x
Object array_front_x1[] = {"bbb", "ccc", "axx", "xzz", "xaa"};
Object array_front_x1_1[] = {"xaa", "xzz", "axx", "bbb", "ccc"};
test(front_x(array_front_x1), Arrays.toString(array_front_x1_1));
// array,s 2 front-x
Object array_front_x2[] = {"ccc", "bbb", "aaa", "xcc", "xaa"};
Object array_front_x2_2[] = {"xaa", "xcc", "aaa", "bbb", "ccc"};
test(front_x(array_front_x2), Arrays.toString(array_front_x2_2));
// array,s 3 front-3
Object array_front_x3[] = {"mix", "xyz", "apple", "xanadu", "aardvark"};
Object array_front_x3_3[] = {"xanadu", "xyz", "aardvark", "apple", "mix"};
test(front_x(array_front_x3), Arrays.toString(array_front_x3_3));
//----------------------------------------------------
// Ok
// Remove adjacent problem
System.out.println( "nremove_adjacent");
// array,s 1 r_adjacent
Object r_adjacent[] = {1, 2, 2, 3};
Object r_adjacent1[] = {1, 2, 3};
test(remove_adjacent(r_adjacent), Arrays.toString(r_adjacent1));
// array,s 2 adjacent
Object r_adjacent2[] = {2, 2, 3, 3, 3};
Object r_adjacent2_2[] = {2, 3};
test(remove_adjacent(r_adjacent2), Arrays.toString(r_adjacent2_2));
// array,s 3 adjacent
Object r_adjacent3[] = {};
Object r_adjacent3_3[] = {};
test(remove_adjacent(r_adjacent3), Arrays.toString(r_adjacent3_3));
//----------------------------------------------------
// Ok
// linear merge Problem
System.out.println("nlinear_merge");
// array,s 1 linear_merge
Object temp_list1[] = {"aa", "xx", "zz"};
Object temp_list1_1[] = {"bb", "cc"};
Object temp_list1_1_1[] = {"aa", "bb", "cc", "xx", "zz"};
test(linear_merge(temp_list1, temp_list1_1), Arrays.toString(temp_list1_1_1));
// array,s 2 linear_merge
Object temp_list2[] = {"aa", "xx"};
Object temp_list2_1[] = {"bb", "cc", "zz"};
Object temp_list2_1_1[] = {"aa", "bb", "cc", "xx", "zz"};
test(linear_merge(temp_list2, temp_list2_1), Arrays.toString(temp_list2_1_1));
// array,s 3 linear_merge
Object temp_list3[] = {"aa", "aa"};
Object temp_list3_1[] = {"aa", "bb", "bb"};
Object temp_list3_1_1[] = {"aa", "aa", "aa", "bb", "bb"};
test(linear_merge(temp_list3, temp_list3_1), Arrays.toString(temp_list3_1_1));
//-----------------------------------------------------------
//------------------------Best of Luck-----------------------
}
}

More Related Content

What's hot

Lenses and Prisms in Swift - Elviro Rocca - Codemotion Rome 2018
Lenses and Prisms in Swift - Elviro Rocca - Codemotion Rome 2018 Lenses and Prisms in Swift - Elviro Rocca - Codemotion Rome 2018
Lenses and Prisms in Swift - Elviro Rocca - Codemotion Rome 2018 Codemotion
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Chih-Hsuan Kuo
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...julien.ponge
 
Sorting Algorithms.
Sorting Algorithms.Sorting Algorithms.
Sorting Algorithms.Saket Kumar
 
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch
 
4. Обработка ошибок, исключения, отладка
4. Обработка ошибок, исключения, отладка4. Обработка ошибок, исключения, отладка
4. Обработка ошибок, исключения, отладкаDEVTYPE
 
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...ssuserd6b1fd
 
Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2Technopark
 
Protocol handler in Gecko
Protocol handler in GeckoProtocol handler in Gecko
Protocol handler in GeckoChih-Hsuan Kuo
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheeltcurdt
 
Email Classifier using Spark 1.3 Mlib / ML Pipeline
Email Classifier using Spark 1.3 Mlib / ML PipelineEmail Classifier using Spark 1.3 Mlib / ML Pipeline
Email Classifier using Spark 1.3 Mlib / ML Pipelineleorick lin
 
The Ring programming language version 1.5.2 book - Part 34 of 181
The Ring programming language version 1.5.2 book - Part 34 of 181The Ring programming language version 1.5.2 book - Part 34 of 181
The Ring programming language version 1.5.2 book - Part 34 of 181Mahmoud Samir Fayed
 
Software Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW SydneySoftware Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW Sydneyjulien.ponge
 
Creating Lazy stream in CSharp
Creating Lazy stream in CSharpCreating Lazy stream in CSharp
Creating Lazy stream in CSharpDhaval Dalal
 

What's hot (20)

Lenses and Prisms in Swift - Elviro Rocca - Codemotion Rome 2018
Lenses and Prisms in Swift - Elviro Rocca - Codemotion Rome 2018 Lenses and Prisms in Swift - Elviro Rocca - Codemotion Rome 2018
Lenses and Prisms in Swift - Elviro Rocca - Codemotion Rome 2018
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36
 
c programming
c programmingc programming
c programming
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
 
Java 7 LavaJUG
Java 7 LavaJUGJava 7 LavaJUG
Java 7 LavaJUG
 
Sorting Algorithms.
Sorting Algorithms.Sorting Algorithms.
Sorting Algorithms.
 
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
 
4. Обработка ошибок, исключения, отладка
4. Обработка ошибок, исключения, отладка4. Обработка ошибок, исключения, отладка
4. Обработка ошибок, исключения, отладка
 
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
 
Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2
 
c programming
c programmingc programming
c programming
 
Protocol handler in Gecko
Protocol handler in GeckoProtocol handler in Gecko
Protocol handler in Gecko
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
 
Rust
RustRust
Rust
 
Email Classifier using Spark 1.3 Mlib / ML Pipeline
Email Classifier using Spark 1.3 Mlib / ML PipelineEmail Classifier using Spark 1.3 Mlib / ML Pipeline
Email Classifier using Spark 1.3 Mlib / ML Pipeline
 
C++11 - STL Additions
C++11 - STL AdditionsC++11 - STL Additions
C++11 - STL Additions
 
The Ring programming language version 1.5.2 book - Part 34 of 181
The Ring programming language version 1.5.2 book - Part 34 of 181The Ring programming language version 1.5.2 book - Part 34 of 181
The Ring programming language version 1.5.2 book - Part 34 of 181
 
Software Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW SydneySoftware Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW Sydney
 
Creating Lazy stream in CSharp
Creating Lazy stream in CSharpCreating Lazy stream in CSharp
Creating Lazy stream in CSharp
 
Migrating to JUnit 5
Migrating to JUnit 5Migrating to JUnit 5
Migrating to JUnit 5
 

Similar to Test string and array

Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfarjuncorner565
 
Apache Flink Training: DataSet API Basics
Apache Flink Training: DataSet API BasicsApache Flink Training: DataSet API Basics
Apache Flink Training: DataSet API BasicsFlink Forward
 
Goroutines and Channels in practice
Goroutines and Channels in practiceGoroutines and Channels in practice
Goroutines and Channels in practiceGuilherme Garnier
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokusHamletDRC
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeDaniel Wellman
 
Logic Equations Resolver J Script
Logic Equations Resolver   J ScriptLogic Equations Resolver   J Script
Logic Equations Resolver J ScriptRoman Agaev
 
Flink Batch Processing and Iterations
Flink Batch Processing and IterationsFlink Batch Processing and Iterations
Flink Batch Processing and IterationsSameer Wadkar
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdfarshiartpalace
 
Game unleashedjavascript
Game unleashedjavascriptGame unleashedjavascript
Game unleashedjavascriptReece Carlson
 
Given the code below create a method called, getCollisionCount that .pdf
Given the code below create a method called, getCollisionCount that .pdfGiven the code below create a method called, getCollisionCount that .pdf
Given the code below create a method called, getCollisionCount that .pdfaucmistry
 
#include iostream #include cstring #include vector #i.pdf
 #include iostream #include cstring #include vector #i.pdf #include iostream #include cstring #include vector #i.pdf
#include iostream #include cstring #include vector #i.pdfanandatalapatra
 
java write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdfjava write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdfarjuntelecom26
 
2019-10-05 - Untangled - Voxxed days ticino
2019-10-05 - Untangled - Voxxed days ticino2019-10-05 - Untangled - Voxxed days ticino
2019-10-05 - Untangled - Voxxed days ticinoArnaud Bos
 
using the code below write the public V add(K key, V value); that ad.pdf
using the code below write the public V add(K key, V value); that ad.pdfusing the code below write the public V add(K key, V value); that ad.pdf
using the code below write the public V add(K key, V value); that ad.pdfamirthagiftsmadurai
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3Dillon Lee
 
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfPROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfclimatecontrolsv
 

Similar to Test string and array (20)

Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
 
Apache Flink Training: DataSet API Basics
Apache Flink Training: DataSet API BasicsApache Flink Training: DataSet API Basics
Apache Flink Training: DataSet API Basics
 
Goroutines and Channels in practice
Goroutines and Channels in practiceGoroutines and Channels in practice
Goroutines and Channels in practice
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
 
Logic Equations Resolver J Script
Logic Equations Resolver   J ScriptLogic Equations Resolver   J Script
Logic Equations Resolver J Script
 
Flink Batch Processing and Iterations
Flink Batch Processing and IterationsFlink Batch Processing and Iterations
Flink Batch Processing and Iterations
 
Java Puzzlers
Java PuzzlersJava Puzzlers
Java Puzzlers
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdf
 
Templates
TemplatesTemplates
Templates
 
Game unleashedjavascript
Game unleashedjavascriptGame unleashedjavascript
Game unleashedjavascript
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
Given the code below create a method called, getCollisionCount that .pdf
Given the code below create a method called, getCollisionCount that .pdfGiven the code below create a method called, getCollisionCount that .pdf
Given the code below create a method called, getCollisionCount that .pdf
 
#include iostream #include cstring #include vector #i.pdf
 #include iostream #include cstring #include vector #i.pdf #include iostream #include cstring #include vector #i.pdf
#include iostream #include cstring #include vector #i.pdf
 
java write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdfjava write a program to evaluate the postfix expressionthe program.pdf
java write a program to evaluate the postfix expressionthe program.pdf
 
2019-10-05 - Untangled - Voxxed days ticino
2019-10-05 - Untangled - Voxxed days ticino2019-10-05 - Untangled - Voxxed days ticino
2019-10-05 - Untangled - Voxxed days ticino
 
Scala Paradigms
Scala ParadigmsScala Paradigms
Scala Paradigms
 
using the code below write the public V add(K key, V value); that ad.pdf
using the code below write the public V add(K key, V value); that ad.pdfusing the code below write the public V add(K key, V value); that ad.pdf
using the code below write the public V add(K key, V value); that ad.pdf
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3
 
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdfPROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
PROBLEM STATEMENTIn this assignment, you will complete DoubleEnde.pdf
 

Recently uploaded

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 

Recently uploaded (20)

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

Test string and array

  • 1. ============================String_Test========================= package com.String_Function; public class String_Fucntion { // Ok // test function is used to test the function input in ok and xx form public final static void test(String get , String expected){ try { // condition used for result if (get.equalsIgnoreCase(expected)){ System.out.print("OK"+" "); }// condition used for reject the result else{ System.out.print("XX"+" "); } } catch (Exception e) { // TODO Auto-generated catch block System.out.println("System not working ");; } } //Ok // donuts and send back to the main for test public final static String donuts(int count){ try { // Condition for donuts if(count == 10 || count > 10){ // if the count is equal the 10 and grater than the 10 return "Number of donuts: many"; }else{ // if the count is less than the 10 than print return "Number of donuts: "+count; } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } } //Ok // both_ends and send back to the main for test public final static String both_ends(String string){ // try { // if the length of the String is one if(string.length() <= 1 || string.isEmpty()){ return ""; }else{ // this return back the both_end String return string.substring(0,2)+""+ new StringBuffer(new StringBuffer(string).reverse().substring(0, 2)).reverse(); } } catch (Exception e) {
  • 2. // TODO Auto-generated catch block e.printStackTrace(); return null; } } //Ok // fix_start and send back to the main for test public final static String fix_start(String string){ // // try { // if(string.isEmpty()){ return null; } // get the temp as String to get the string who value is less than one the real string String temp = string.substring(1); // return the real fix_start String to the test return string.charAt(0)+temp.replaceAll(string.charAt(0)+"", "*"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } } // Ok // mix and send back to the main for test public final static String mixUp(String string, String string2){ try { // return the mix string and test it return string.replace(string.subSequence(0, 2), string2.subSequence(0, 2))+" "+string2.replace(string2.subSequence(0, 2), string.subSequence(0, 2)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } } //Ok // verbing and send back to the main for test public final static String verbing(String string){ // try { // if the length of the String is less than 3 than not change the string and send same back if(string.length() < 3){ // send the same string that i received for the parameter return string; }else{ // if the string is ing than return back the same if(string.contains("ing") && string.length() == 3){ // this one used when it containing the ing in the text return string;
  • 3. }else if(string.contains("ing")){ // if true than concat the old string with ly return string+"ly"; }else{ // if flase than concat the onl string with ing return string+"ing"; } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } } // Ok // not bad and send back to the main for test public final static String not_bad(String string){ // try { // condition for not and bad contains in the string if(string.contains("not") && string.contains("bad")){ // if yes than watch not is first come and bad is lass if(string.indexOf("not") < string.indexOf("bad")){ // return back to the main return string.replace(string.substring(string.indexOf("not")), "good"); // if the bad is first and not is lass than is will work }else if(string.indexOf("not") > string.indexOf("bad")){ // than send the same string that get from the parameter // send the same the string return string; } }else{ // send the same the sting // if only not and only bad contains in the string return string; } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } return null; } //Ok // front back and send back to the main for test public final static String front_back(String string , String string2){ // condition for both equal length if(string.length()%2 == 0 && string2.length()%2 == 0){ // send back to the main return string.substring(0, string.length()/2)+string2.substring(0,string2.length()/2)+string.substring(string.length( )/2)+string2.substring(string2.length()/2); }else{ // condition for first even and second odd if(string.length()%2 == 0 && string2.length()%2 == 1){
  • 4. // send back to the mian return string.substring(0, string.length()/2)+string2.substring(0,string2.length()/2+1)+string.substring(string.lengt h()/2)+string2.substring(string2.length()/2+1); }else{ // this one work when both string are odd // send back to the main return string.substring(0, string.length()/2+1)+string2.substring(0,string2.length()/2+1)+string.substring(string.len gth()/2+1)+string2.substring(string2.length()/2+1); } } } // // public static void main(String args[]){ // System.out.println ("donuts"); // Each line calls donuts, compares its result to the expected for that call. test(donuts(4), "Number of donuts: 4"); test(donuts(9), "Number of donuts: 9"); test(donuts(10), "Number of donuts: many"); test(donuts(99), "Number of donuts: many"); //----------------------------------------- // Each line calls both_end, compares its result to the expected for that call. System.out.println("nboth_ends"); test(both_ends("spring"), "spng"); test(both_ends("Hello"), "Helo"); test(both_ends("a"), ""); test(both_ends("xyz"), "xyyz"); //----------------------------------------- //Each line calls fix_start, compares its result to the expected for that call. System.out.println("nfix_start"); test(fix_start("babble"), "ba**le"); test(fix_start("aardvark"), "a*rdv*rk"); test(fix_start("google"), "goo*le"); test(fix_start("donut"), "donut"); //---------------------------------------- //Each line calls mixUp, compares its result to the expected for that call. System.out.println("nmix_up"); test(mixUp("mix", "pod"), "pox mid"); test(mixUp("dog", "dinner"), "dig donner"); test(mixUp("gnash", "sport"), "spash gnort"); test(mixUp("pezzy", "firm"), "fizzy perm"); //--------------------------------------- //Each line calls verbing, compares its result to the expected for that call. System.out.println("nverbing"); test(verbing("hail"), "hailing"); test(verbing("swiming"), "swimingly"); test(verbing("do"), "do"); test(verbing("ing"),"ing"); //-------------------------------------- //Each line calls not_bad, compares its result to the expected for that call. System.out.println("nnot_bad"); test(not_bad("This movie is not so bad"), "This movie is good");
  • 5. test(not_bad("This dinner is not that bad!"), "This dinner is good"); test(not_bad("This tea is not hot"), "This tea is not hot"); test(not_bad("It's bad yet not"), "It's bad yet not"); //------------------------------------- //Each line calls front_back, compares its result to the expected for that call. System.out.println("nfront_back"); test(front_back("abcd", "xy"), "abxcdy"); test(front_back("abcde", "xyz"), "abcxydez"); test(front_back("Kitten", "Donut"), "KitDontenut"); } } =============================== ListTest ==================================== package com.String_Function; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; // public class List_Reddal { //Ok // test the both String and List public final static void test(Object get , Object expected){ try { // condition used for result if (get.toString().equalsIgnoreCase(expected.toString())){ System.out.print("OK"+" "); }// condition used for reject the result else{ System.out.print("XX"+" "); } } catch (Exception e) { // System.out.println("System not working ");; } } // Ok // test the match ends and send back to the main public final static Object match_ends(Object match_e[]){ try { // count the word int count_end = 0; // get the single word
  • 6. Object get_word; // break the word into the single char but the type is Object Object temp = null,temp2 = null; // used the loop to access the array index for(Object match_key : match_e){ // assign the word to the single object get_word = match_key.toString(); // condition for null or empty String if(!get_word.equals("")){ // get the first single letter but the type is Object temp = get_word.toString().charAt(0); // get the last single letter but the type is Object temp2 = get_word.toString().charAt(get_word.toString().length()-1); // condition for both first and end are equal if true it count else not if(temp.toString().equalsIgnoreCase(temp2.toString())){ count_end += 1; } } } // return the Result of the Process return count_end; // catch used to handle the exception } catch (Exception e) { // if the exception is rise it show the message of the error return "Indext out of Range The Error are found in method match_End"; } } // Ok // test the front_x and send back to the main public final static Object front_x(Object f_x[]){ // get the two array // array with_x ArrayList<Object> array_with_xs = new ArrayList<Object>(); // array with_out x ArrayList<Object> array_without_xs = new ArrayList<Object>(); // loop for adding the item individual for (Object object : f_x) { // condition for front_X if((object.toString().charAt(0) == 'x') || (object.toString().charAt(0) == 'X')){ // add the front_x array_with_xs.add(object); }else{ // add the non_Front_x array_without_xs.add(object); } } // sort the both the array
  • 7. Collections.sort(array_with_xs,null); // Collections.sort(array_without_xs,null); // // know Combine the both array,s into the array_with_xs for (Object object : array_without_xs ) { array_with_xs.add(object); } // send array for test return array_with_xs.toString(); } // Ok // test the sort_last and send back to the main public final static Object sort_last(Object array_sort_last_1[][]){ // Method work only Integer // get the temp array for single index change Object temp1[]; // loop's work like a sort-ing // outer-loop for(int i = 0; i < array_sort_last_1.length-1; i++) { // inner-loop for (int j = i+1; j < array_sort_last_1.length; j++) { // condition watch // (Integer) casting required to convert the object element into the Integer if(((Integer) array_sort_last_1[i][array_sort_last_1[i].length-1] > (Integer) array_sort_last_1[j][array_sort_last_1[j].length-1])){ // sewap_ing apply_ing on the address of the array not on item temp1 = array_sort_last_1[i]; array_sort_last_1[i] = array_sort_last_1[j]; array_sort_last_1[j] = temp1; } } } // send array for test return Arrays.deepToString(array_sort_last_1); } // Ok // test the remove_adjacent and send back to the main public final static Object remove_adjacent(Object r_adjacent[]){ // get the temp array and pass the all element // of the first array into the temp ArrayList<Object> temp_Array = new ArrayList<Object>(); // loop used to get the single item at one time for (Object object : r_adjacent) { // if it contains the object into the array it //become false and not item more add to the temp if(!(temp_Array.contains(object))){ // add teh single object to the temp_Array temp_Array.add(object);
  • 8. } } // return the array as the type of string return temp_Array.toString(); } // Ok // test the linear_merge and send back to the main public final static Object linear_merge(Object list1[], Object list2[]){ // // merge mean combine to list into single list ArrayList<Object> object = new ArrayList<Object>(); // add the first list for (Object object1 : list1) { // condition for front_X object.add(object1); } // add the second list for (Object object2 : list2) { // condition for front_X object.add(object2); } // sort the list by use of the Collection Collections.sort(object,null); return object.toString(); } // // Main Method public static void main(String[] args) { //Ok // Match_end problem System.out.println("Match_End"); // array 1 match_ends Object array[] = {"xxa",121, "aa", "x", "bbb"}; test(match_ends(array), 4); // array 2 match_ends Object array1[] = {"", "xyw", "xy", "xyx", "xx"}; test(match_ends(array1), 2); // array 3 match_ends Object array2[] = {"aaA", "be", "abc", "hello"}; test(match_ends(array2), 1); //------------------------------------------------- // Ok // Sort problem System.out.println("nSort_last"); // array,s 1 sort_last Object array_sort_last_1[][] = { {1, 3}, {3, 2}, {2, 1}}; Object array_sort_last_1_1[][] = { {2, 1}, {3, 2}, {1, 3}}; test(sort_last(array_sort_last_1), Arrays.deepToString(array_sort_last_1_1));
  • 9. // array,s 2 sort_last Object array_sort_last_2[][] = {{2, 3},{1, 2},{3, 1}}; Object array_sort_last_2_2[][] = {{3, 1}, {1, 2}, {2, 3}}; test(sort_last(array_sort_last_2), Arrays.deepToString(array_sort_last_2_2)); // array,s 3 sort_last Object array_sort_last_3[][] = {{1, 7}, {1, 3}, {3, 4, 5}, {2, 2}}; Object array_sort_last_3_3[][] = {{2, 2}, {1, 3}, {3, 4, 5}, {1, 7}}; test(sort_last(array_sort_last_3), Arrays.deepToString(array_sort_last_3_3)); //------------------------------------------------- // Ok // Front_end problem System.out.println("nFront_X"); // array,s 1 front-x Object array_front_x1[] = {"bbb", "ccc", "axx", "xzz", "xaa"}; Object array_front_x1_1[] = {"xaa", "xzz", "axx", "bbb", "ccc"}; test(front_x(array_front_x1), Arrays.toString(array_front_x1_1)); // array,s 2 front-x Object array_front_x2[] = {"ccc", "bbb", "aaa", "xcc", "xaa"}; Object array_front_x2_2[] = {"xaa", "xcc", "aaa", "bbb", "ccc"}; test(front_x(array_front_x2), Arrays.toString(array_front_x2_2)); // array,s 3 front-3 Object array_front_x3[] = {"mix", "xyz", "apple", "xanadu", "aardvark"}; Object array_front_x3_3[] = {"xanadu", "xyz", "aardvark", "apple", "mix"}; test(front_x(array_front_x3), Arrays.toString(array_front_x3_3)); //---------------------------------------------------- // Ok // Remove adjacent problem System.out.println( "nremove_adjacent"); // array,s 1 r_adjacent Object r_adjacent[] = {1, 2, 2, 3}; Object r_adjacent1[] = {1, 2, 3}; test(remove_adjacent(r_adjacent), Arrays.toString(r_adjacent1)); // array,s 2 adjacent Object r_adjacent2[] = {2, 2, 3, 3, 3}; Object r_adjacent2_2[] = {2, 3}; test(remove_adjacent(r_adjacent2), Arrays.toString(r_adjacent2_2)); // array,s 3 adjacent Object r_adjacent3[] = {}; Object r_adjacent3_3[] = {}; test(remove_adjacent(r_adjacent3), Arrays.toString(r_adjacent3_3)); //---------------------------------------------------- // Ok // linear merge Problem System.out.println("nlinear_merge"); // array,s 1 linear_merge Object temp_list1[] = {"aa", "xx", "zz"};
  • 10. Object temp_list1_1[] = {"bb", "cc"}; Object temp_list1_1_1[] = {"aa", "bb", "cc", "xx", "zz"}; test(linear_merge(temp_list1, temp_list1_1), Arrays.toString(temp_list1_1_1)); // array,s 2 linear_merge Object temp_list2[] = {"aa", "xx"}; Object temp_list2_1[] = {"bb", "cc", "zz"}; Object temp_list2_1_1[] = {"aa", "bb", "cc", "xx", "zz"}; test(linear_merge(temp_list2, temp_list2_1), Arrays.toString(temp_list2_1_1)); // array,s 3 linear_merge Object temp_list3[] = {"aa", "aa"}; Object temp_list3_1[] = {"aa", "bb", "bb"}; Object temp_list3_1_1[] = {"aa", "aa", "aa", "bb", "bb"}; test(linear_merge(temp_list3, temp_list3_1), Arrays.toString(temp_list3_1_1)); //----------------------------------------------------------- //------------------------Best of Luck----------------------- } }