Enciphering And Deciphering Message Using Provided Keyword

May 23, 2014

I need creating a java keyword program that can encipher and decipher a message using the provided keyword.

The keyword is :javbean

I have attached the message text as well...

public class Caesarcipher
{
public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz";
public static void main(String[] args)
{
String theKey = "JAVBEANDEFGHIJKLMNOPQRSTUVWXYZ";
String text= "message.txt";

[Code] ....

message.txt (763bytes)

View Replies


ADVERTISEMENT

Difference Between Static Keyword And Transient Keyword

Oct 7, 2014

What is the difference between the static keyword and transient keyword?

View Replies View Related

Designing Jar File Where Access Of Certain Database Provided Through API

Jan 30, 2015

I'm given a task to generate an API (a jar file) where the access of a certain database is provided through the API. basic functionality: Client sends a query through the API to server and the Server responds with data.Since its and API, do I have to implement the code or is it enough if i gave just interfaces? what are the OOP concepts to focus on when designing a good API.

View Replies View Related

Result Of Encoded Message Cannot Restore To Original Message By Decoder

Sep 28, 2014

The problem is the result of encoded message can't not restore to the original message by the decoder. Here are my three class's code

SecureMsgMain:

package securemsg.core;
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
 import securemsg.database.*;
 public class SecureMsgMain {
 
[Code] .....

View Replies View Related

For Loop To Convert Any Number Entered To Base 10 With Any Base Provided

Oct 9, 2014

So i'm writing a for loop to convert any number entered to base 10 with any base provided as well. My code does not work because I need a way to reverse the code order, so the new number is printed correctly with the given base. My code so far:

public static void main (String[] args) {
Scanner kb = new Scanner (System.in);
System.out.print("Enter a number :: ");
int numOriginal = kb.nextInt();
System.out.print("Enter a base :: ");
int base = kb.nextInt();

[Code] .....

newBase has a problem with how it calculates the new number, looking for correct newBase code for conversion?

View Replies View Related

Generics Super Keyword

Feb 14, 2014

Suppose I have

class A {
public void speak() {
System.out.println("I am class A");
}
}

class B extends A{
public void speak() {
System.out.println("I am class B");
}
}

class C extends B{
public void speak() {
System.out.println("I am class C");
}
}

Why this doesn't work while A is a super type of B ?

public static void insertElements(List<? super B> list){
list.add(new A()); //not OK, why?
}

View Replies View Related

Why Use Extends Keyword Instead Of Implements In Generics

Feb 22, 2015

Why java uses the keyword extends when setting the bound of a type parameter(Generic) to an interface. I think using the keyword implements is more intuitive.

public static <T extends Comparable<T>>

why use extends? and not implements.

int countGreaterThan(T[] anArray, T elem) {
int count = 0;
for (T e : anArray)
if (e.compareTo(elem) > 0)
++count;
return count;
}

I know if I want to set multiple bounds I will use extends keyword, and I will concatenate the bounds using & operator.

Is this a design decision to always use extends keyword to set bounds?

View Replies View Related

Static Keyword For Arraylist Containing Objects

Jun 14, 2014

I've come across something that i'm not overall sure about regarding the static keyword in Java.I'm making a vertical scrolling game where the player simply shoots enemies and they shoot back as they fall, dropping items if they die such as power ups and coins. I have an enemy called Bat and this is the bullet creation code in the update method:

if(oldPlayerY + 220 > posY && getBulletDelay > 0.90f){
batBullets.add(new Bullet(posX + 10, posY - 10));
getBulletDelay = 0;
}

The method is creating a new bullet object and it then adds that to the arraylist called batBullets, which is simple enough. I then need to access this arraylist in the main game update class so I can render those bullets on the screen, even if the bat dies. I was always taught that you use the static keyword when you need to access something from the class that doesn't require an object. Because of this, I have the following code.

for(Bullet bullet : Bat.batBullets){
bullet.setY(bullet.getY - 5); // Set the bullet to fall
renderMap.getSpriteBatch().draw(bullet.batBullet(), bullet.getX(), bullet.getY()); // render the bullets
}

This seems perfectly fine to me because I need to access the batBullet arraylist and it doesn't make sense to create a new bat object as I already have random spawning in place for them.

View Replies View Related

How Registry Can Look Before Java Install - Keyword

Dec 2, 2014

I am attaching a document which shows the current state of my registry.What I want to know is if I can [safely] delete the JavaSoft folder with all lower subfolders, then re-install jdk1.6/0_31 which, I am told, is the current version being used here by developers.According to others on the development team (not my team), there COULD be something in the registry that is preventing both the installation of java jdk AND its uninstallation.Since I cannot seem to attach any kind of document.

View Replies View Related

Super Keyword When Used Explicitly In A Subclass Constructor

Jul 9, 2014

The super keyword when used explicitly in a subclass constructor must be the first statement but what about if i have a this(parameters) statements ? As the this one must also be the first statement... Does this means that i can have only one or the other ? What about when the super constructor is not explicit (aka implicit ) , can i use the this( parameters) in the same constructor ?

View Replies View Related

Formatting Exception Output - Keyword Not Found

Nov 7, 2014

I've been trying for a while to get my exception output to print in a particular form to System.err.

What I'm looking for as output is

KeywordException: edu.cofc.csci221.KeywordException: **Keyword Not Found**

I'm getting

Keyword Exception: edu.cofc.csci221.KeywordException
at edu.cofc.csci221.CheckLine.checkForInvalidKeyword(CheckLine.java:101)
at edu.cofc.csci221.ReadLogFile.main(ReadLogFile.java:47)

The code:

line = scan.nextLine();
try { check.checkForInvalidSymbols(line); } catch (SymbolException sEx) { System.err.print("Symbol Exception: "); sEx.printStackTrace(); }
try { check.checkForInvalidKeyword(line); }catch (KeywordException kEx) { System.err.print("Keyword Exception: "); kEx.printStackTrace(); }
if(check.checkFirstKeyword(line) && line.split(" ")[0].equals(keywords[0])) { System.out.println(line); }

[Code] ....

I'm just unsure of where to go/what to do.

View Replies View Related

Display Name Of All People In ArrayList Containing Passed In Keyword

Dec 8, 2014

i need to write a method, that passes in an arraylist and a keyword,and display the name of all the people in the arrayList whose name contain the keyword (irrespective of uppercase or lowercase). how to write such a method ??

View Replies View Related

Program Shows Error While Using Super Keyword

Jan 3, 2015

//constructor
class Base
{
Base(int a) {
System.out.println("in base"+a);;
}
}
class Cons extends Base

[Code] .....

View Replies View Related

How Does Keyword In CoffeeSize Class Refer To Size Of Coffee

Feb 20, 2015

How does the keyword this in the CoffeeSize class refer to the size of the coffee ? I am also confused as to how the CoffeeSize constructor comes into play to determine the cost.

public class Test
{
public static void orderCoffee(CoffeeSize size)
{
size.print();
}
public static void main(String[] args)
{
orderCoffee(CoffeeSize.SMALL);
}

[code]....

View Replies View Related

Why Keyword Is Needed Infront Of Abstract Class Methods

Mar 7, 2014

I have a simple classes here one is interface and another one is abstract class when i try to compile them abstract class is givving compilation error.

public interface MyInterface{
public void getName();
public void getName(String s);
}
public class HelloWorld{}
abstract class SampleClass{

[code]....

View Replies View Related

Taking Object As Input - Instanceof Keyword Test

Feb 7, 2014

I am trying to test the instanceof keyword. To do this, I've made a method with a simple logical test like so:

Java Code:

Vehicle vehicle1 = new Vehicle();
public void Type(){
if (vehicle1 instanceof Vehicle) {
System.out.println("Type = Vehicle");
}
else if (vehicle1 instanceof Car) {
System.out.println("Type = Car");
}
else if (vehicle1 instanceof Truck) {
System.out.println("Type = Truck");
}
}
} mh_sh_highlight_all('java');

I wanted to try implementing it into the class definitions for Vehicle, then extend that to Car and Truck, but I'm not sure how to use this test in a general case.

The only way this method works is if I set the test to specifically accept a specific object as a parameter.

I want to test multiple objects, but I'm not really sure how else to do this without simply copy-pasting the logical test multiple times and changing the respective objects that are used as parameters.

View Replies View Related

Searching TXT File For A Specific Keyword And Output Whole Line

Feb 12, 2014

I need to search a txt file for a specific keyword and then output all the lines that contain that keyword. Right now I I think I have my search done but I don't know how I would print the whole line.

TextIO.readFile("xxx.txt");
String search;
String word;
int count=0;
TextIO.put("Please enter your search word: ");
search = TextIO.getln();
while (!TextIO.eof()) {
word = TextIO.getln();
count = count+1;
if (search.equalsIgnoreCase(word)==true){
TextIO.put(count + "-");
TextIO.put(word);

Right now it doesnt even let me enter in any values for the search. Not sure what I've done wrong..

View Replies View Related

Eclipse Does Not Recognize Default Method Keyword And Lambda Expression

Jun 2, 2014

I have this very annoying issue with Eclipse (I have the latest version installed). For some reason, every time I use the "default" keyword in an interface, it gives me an error similar to "Syntax error on token default",  I deleted the "default" keyword, the error is gone. The same thing happens with "Lambda expression as well", say I have this object like this :

Actions myActions = () -> {System.out.print("Blah blah blah");};   ,

Eclipse also displays the error message similar to "Method body expected after (), delete '->' ". I checked the Java version I have, it is the latest one also ....

View Replies View Related

Instant Message GUI

Mar 14, 2014

import java.awt.*;
import javax.swing.*;
public class InstantMessageFrame extends JFrame
{
private JList friends;
private JTextField message;
private JButton send;

[code]...

1. Open the source code file of your InstantMessageFrame class from Lab 12.2.

2. Add the following three fields to the InstantMessageFrame class: a JTextField named message, a JList named friends, and a JButton named send.

3. Add a method to your InstantMessageFrame class named getMessagePanel()that returns a JPanel and has no parameters. (This method will create a JPanel that will appear in the south border of your JFrame. It will contain a text field in which a message can be entered and a button that sends an instant message to all the friends in the list.)

4. Within getMessagePanel(), instantiate a new JPanel and give it BorderLayout.Assign a message equal to a new JTextField by using the no-argument constructor of JTextField. Assign send to a new JButton,passing in "Send" to the constructor. (This will be the label on the button.)

5. Within getMessagePanel(), add the message text field to the center of the JPanel and add the send button to the east border of the JPanel. The panel is now ready, so return the JPanel reference.

6. Add a method to your InstantMessageFrame class named get-FriendsPane() that returns a JScrollPane and has no parameters.(This method will create a scrollable list that will contain the names of others that you can chat with.)

7. Within getFriendsPane(), assign friends to a new JList by using theno-argument constructor of JList.

8. Within getFriendsPane(), instantiate a new JScrollPane using the following statement: JScrollPane pane = new JScrollPane(friends);

9. The scroll pane is ready, so return the reference pane at the end of getFriendsPane().

10. Within the constructor of InstantMessageFrame, invoke getMessagePanel(),placing the returned panel in the south border of the content pane of InstantMessageFrame.An Introduction to GUI Programming 399

11. Within the constructor of InstantMessageFrame, invoke get-FriendsPane(), placing the returned scroll pane in the center of the content pane of InstantMessageFrame.

12. Save, compile, and run the InstantMessageFrame class.Your InstantMessageFrame now has three visible components: a JList,a JTextField, and a JButton.

View Replies View Related

Error Message Debug

Mar 11, 2014

I'm very new to java code I'm currently learning about loops I've tried to write this for a statement in the program I'm making but its not working. I keep getting this message

LoanQualifier.java:26: error: illegal start of expression
if (salary >0||<=250000)
^
LoanQualifier.java:28: error: illegal start of type
if (yearsOnJob >0||<50)

I'm using Jgrasp for a complier

View Replies View Related

Socket Should Only Read One Message

Apr 4, 2015

if i send messages as in the code below, is there a way to read only one message, if the client doesn't know how long it is (or if he only knows the maximum length)?in the documentation it says, that the method read(byte[]) reads until no data ist available or end of file is decteted. What does the latter mean? Can i extend the array that i sent by a byte that signals the end? Here is my Code:

Server

public class Server implements Runnable{
 ServerSocket server;
HashMap<Short,Socket> clients;
 public Server(){
clients = new HashMap<>();

[code]....

Both are startet in seperate threads. At the moment the first output of the client is "12 bytes read", and then continously "-1 bytes read"(because the server closes).

View Replies View Related

EJB / EE :: How To Pass XML File As Message In JMS

Apr 22, 2014

I am new to the JMS technology. I have written one sample sender and receiver program to pass a string message to the JMS queue and retrieve it back. It is working fine as well. But now, I want to pass a xml file to the JMS queue. Then from there I need to read the XML file and convert it into a Java object Using Jaxb. I know how to convert an XML into java object using Jaxb. But i am unable to send the XML file as a jms message to the listener.

View Replies View Related

How To Send A Message To A Client

Jan 22, 2015

I want to send a message to a specific client in a server. This is my code and what I tried(I have only given you 3 classes in which I believe I have the problem).

TextClient:
import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
public class TextClient {
public TextClient() {

[Code]...

View Replies View Related

JSF :: Message Resource Bundle

Sep 17, 2014

Im debugging a code that has the following setting:

<application>
<message-bundle>com.web.resources</message-bundle>
<locale-config>
<default-locale>en_US</default-locale>
<supported-locale>fr_FR</supported-locale>
</locale-config>
<resource-bundle>
<base-name>com.web.resources.message</base-name>
<var>message</var>
</resource-bundle>
</application>

Just want to ask, for example I have message_en_US.properties and message_en_SG.properties.And the web is currently using the SG property but one property is not exist on it, can I just redirect to use the US property?

View Replies View Related

EJB / EE :: Program To Post Message To IBM MQ

Oct 16, 2014

I wrote stand alone program to post message to IBM MQ , not sure if it posted to queue i see these Another 2,102 character(s) omitted is that mean it didnt post complete message? do i have to increase capacity of text size

JMS Message class: jms_text
JMSType: null
JMSDeliveryMode: 2
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: ID:414d512042454c4b2e4d49462e514d47ad662c5420128a02
JMSTimestamp: 1413500135480

[Code]...

View Replies View Related

How To Split A String Message

Nov 11, 2014

String path = "/AUTOSAR/Os_0?type=EcucModuleConfigurationValues";
String path1[] = path.split("?type");

I want to split string in such a way that I should get the content before "?" in an another variable. I tried various way but some how I am not getting expected behavior.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved