Java Saved Program: fragrant-terrain

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;

class Script
{
	public static void main (String[] args)
	{
	    Scanner skener = new Scanner(System.in);
        CaesarCipher poruka = new CaesarCipher("Kosava, kosava, kosava, ovdje bonaca, bonaca, bonaca, prijem");
        poruka.code();
        System.out.println(poruka.getSecretMessage());
	}
}

abstract class Coding
{
    protected String Message;
    
    public Coding(String message)
    {
        this.Message = message;
    }
    
    public void setMessage(String message)
    {
        this.Message = message;
    }
    
    public String getMessage()
    {
        return this.Message;
    }
    
    abstract void code();
}

class CaesarCipher extends Coding
{
   private String SecretMessage;
   
   public CaesarCipher(String message)
   {
       super(message);
   }
   
   public void code()
   {
       this.SecretMessage = "";
       for(int i=0; i < this.Message.length(); i++)
       {
           this.SecretMessage += (char)(this.Message.charAt(i) + 2);
       }
   }
   
    public String getSecretMessage()
    {
        return this.SecretMessage;
    }
}





Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs