Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Day11A {
- public static void main(String[] args) {
- CaesarCipher callCipher = new CaesarCipher();
- String refTxt = "Joysis B8";
- String resultTxt;
- callCipher.setTxtIn(refTxt);
- callCipher.setIsEncrypt(true);
- resultTxt = callCipher.getTxtOut();
- System.out.println("reference: " + refTxt);
- System.out.println("result: " + resultTxt);
- }
- }
- class CaesarCipher {
- private String txtIn;
- private String txtOut;
- private boolean isEncrypt;
- /**
- * @param txtIn the txtIn to set
- */
- public void setTxtIn(String txtIn) {
- this.txtIn = txtIn;
- }
- /**
- * @return the txtOut
- */
- public String getTxtOut() {
- if (isEncrypt) {
- encode();
- }
- return txtOut;
- }
- /**
- * @param isEncrypt the isEncrypt to set
- */
- public void setIsEncrypt(boolean isEncrypt) {
- this.isEncrypt = isEncrypt;
- }
- private void encode() {
- int direction = -3;
- char[] txtArray = txtIn.toCharArray();
- for (int i = 0; i < txtArray.length; i++) {
- if ( (____ && _____) || (_____ && ______)) { // D~Z d~z
- txtArray[i] += direction;
- } else if ((____ && _____) || (_____ && ______)) { // ABC abc
- txtArray[i] += 23;
- }
- }
- txtOut = new String(txtArray);
- }
- }
- //--------------------------------------------
- public class Day11C {
- public static void main(String[] args) {
- int num1 = 12, num2 = 0, numRes;
- //String test = "123.66";
- //System.out.println(test + " : " + NumberUtils.isCreatable(test));
- //test = "-123.66";
- //System.out.println(test + " : " + NumberUtils.isCreatable(test));
- //test = "123.66a";
- //System.out.println(test + " : " + NumberUtils.isCreatable(test));
- try {
- numRes = num1 + num2;
- System.out.println("result +: " + numRes);
- numRes = num1 / num2;
- System.out.println("result /: " + numRes);
- numRes = num1 - num2;
- System.out.println("result -: " + numRes);
- } catch (Exception e) {
- System.out.println("ay may mali");
- System.out.println(e);
- }
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- package week2;
- public class Day11D {
- public static void main(String[] args) {
- String[] numList = {"12", "42" ,"3E", "55", "twelve", "88"};
- int currNum, total = 0;
- for (int i = 0; i <= numList.length; i++) {
- try {
- currNum = Integer.parseInt(numList[i]);
- total += currNum;
- System.out.print(currNum + (i < numList.length ? " + " : " = "));
- } catch (Exception e) {
- System.out.println(">> " + e.toString());
- }
- }
- System.out.println("Total: " + total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement