How To Make Shift Encoder / Decoder

Oct 16, 2014

I am working on a project where we need to make a shift encoder/decoder. Right now I am working on my prepareString method, and I have no way of testing it yet. I was just wondering if I wrote it correctly. It should pull in the user entered string and check if each character is a letter, and remove all that are not. Then it should turn all the letters to upper case. Based on that does this look right?

private String prepareString(String plainText)
{
int strLength = plainText.length();
for(int i = 0; i < strLength; i++)
{
char c1 = plainText.charAt(i);
boolean isLetter = Character.isAlphabetic(c1);
if(isLetter == false)

[Code]...

View Replies


ADVERTISEMENT

Java Binary Encoder And Decoder Program

Aug 2, 2014

I have made a Java Binary Encoder and Decoder program and, to date, this is the program I have spent the most time developing.

I have ran Alpha tests to check the functionality is correct and it appears to work well. However I am more interested in the quality of my code ,

The code can be found over at: [URL] ....

View Replies View Related

Encoder - Possibility Of Shift Being Larger Than Alphabet Array Length

Apr 20, 2015

I have an encoder that will shift the character of a string X places. Im trying to account for the possibility of the shift being larger than alphabet array length. I've come up with the following, but I still get an ArrayIndexOutOfBounds Error and it never gets past the if statement.

private String encryption(char charArrayElement) {
String [] alphabet = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L",
"M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
String str = String.valueOf(charArrayElement);

[Code] ....

View Replies View Related

Decoder Ring - Prompt User For A Message To Decode

Nov 7, 2014

So it is the question: This program implements a simple "decoder ring". It will prompt the user for a message to decode and decode the message based on the following substitution rules:

ABCDEFGHIJKLMNOPQRSTUVWXYZ will map to
ZEBRASCDFGHIJKLMNOPQTUVWXY

abcdefghijklmnopqrstuvwxyz will also map to
ZEBRASCDFGHIJKLMNOPQTUVWXY

any other characters (like space, punctuation, will map to themselves)

so if it sees an 'A' (or an 'a'), it will map to 'Z', etc... All i could think of is this but can't figure out the rest.

import java.util.Scanner;
public class DecoderRing
{
public static void main(String[] args)
{
String1[] = 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z';
String2[] = 'Z','E','B','R','A','S','C','D','F','G','H','I','J','K','L','M','N','O','P','Q','T','U','V','W','X','Y';
}
}

Not sure, what things are necessary such as switch statements or if and else or for loops and such...

View Replies View Related

Rotate Left Bitwise Shift?

May 13, 2014

I'm trying to replicate the rol(rotate left) instruction in assembly though can only get as far as shifting the bits with '<<' or doing Long.rotateLeft(var, 5). Both of these method don't wrap around the bits as the rol instruction does.

View Replies View Related

Encoding A Message Using Caesar Shift

Feb 9, 2014

I have an assignment, similar to ones of seen in the past. The assignment is to take a users text input and to encrypt it using 3 different types of encryptions: Caesar, Transpose, and Reverser. The professor gave us the bulk of the code, and more specifically how to tokenize and shift the letters using Caeser shift. The problem im coming across is that it is not showing anything past the users input. After running it, it just stays there running without showing anything.

Cipher:

package cipher;
import java.util.Scanner;
import java.util.StringTokenizer;
import javax.swing.JOptionPane;
public abstract class Cipher {
public String message;
StringBuilder encrypted_message, decrypted_message;

[Code] ....

The constants have their own separate class, and they appear to work fine. I know that the Transpose and Reverser are incomplete, hence them commented out. But if i cant finish with Caeser first, it wont work at all.

View Replies View Related

How To Create A New Line Feed Character In SHIFT JIS File

Aug 29, 2014

NewLine.PNG

I need creating the end of line character on line 2 of the attached image.

When I try with

and

I get the end of line symbol on line 1. I tried converting ASCII 10 to a character and putting that in the file, but I still get the end of line symbol on line one.

I'm using Sakura as the text editor.

View Replies View Related

Shift-left Array Values - How To Assign Divisors Indexes To Start

Dec 16, 2014

I am writing a program for a game. It is between the user and a virtual player. The game starts with a pool of consecutive integers 1-100. The size of the pool is based on a random generated number at the beginning of the game. At the start, both players' scores are 0. For each turn, the player picks one number from the pool. That value is added to the player's score, the computer gets the sum of all the remaining numbers in the pool that divide evenly into the player's pick. The player's pick and its divisors are then removed from the pool.

The player should be able to play the game as many times as she wants without ending the program. Instructions should appear on the screen only once at the start of the program.

For each turn, both players' current score, the current pool of numbers, and a prompt for a number to be entered should show onscreen. I have written the code until I get to the function that updates the pool of numbers after a turn.

import java.util.Scanner;
import java.util.Random;
public class SlickPick {
public static void main (String[] args){
Scanner read = new Scanner(System.in);
int []pool = new int[100];

[Code] ....

My thinking is that I need to use the binary search to find the indexes of the divisors array and then use those indexes as the start values. I'm not sure how to assign the divisors indexes to start. Do I need an array for start? Whenever I run the program, the only value missing is 3.

//Name : poolUpdate
//Description : This function modifies the contents of the pool as a result of a turn of play.
//Parameters : The pool array, the divisors array, the size, and the user's pick.
// :
//Return :
public static void poolUpdate(int[] pool, int[] divisors, int size, int pick){
int low=0;
int high=size-1;

[Code] ....

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

Make Shapes Besides Making Two Lines For X And Oval With White Smaller Oval Inside To Make O

May 8, 2014

We are making a tic tac toe game for my CS120 class and I am having trouble figuring out how to make our X's and O's. Is there a way to make shapes besides making two lines for an X and an oval with a white smaller oval inside to make an O? We have only learned the basics so far in class (i.e. events, inheritance, client-supplier, etc.)

These are our instructions:

Write a controller that controls the game. There is one human player (the X player) and the computer player (the O player). The name of the class must be TicTacToeController. In a sense, the controller is the game since the controller will 1) create a TicTacToeModel 2) create a TicTacToeView and 3) create a TicTacToeButton (you must write this class following the design pattern covered in class lectures), a label, and text field such that when the button is pushed, the player moves into the cell selected by the text field. After every player move, the computer moves into a randomly selected empty cell. When the game is over, a text message must be displayed somewhere on the screen the gives the status of the game. While you are free to change the appearance of the controller, the basic elements must be provided (a view of the game, a button, and a text field to enter the cell). A sample screenshot is displayed below.And this is the code i have thus far:

[import java.awt.*;
import javax.swing.JFrame;
public class TicTacToeView extends Rectangle
public TicTacToeView(int x, int y, int w, int h) {
super(50,60,w,h);
this.setBackground(Color.red);
JFrame win = new JFrame("Tic Tac Toe");
win.setBounds(10,10,w+100, h+100);
win.setLayout(null);
win.setVisible(true);
win.setBackground(Color.gray);

[code]....

View Replies View Related

How To Make Palindrome

Aug 16, 2014

I want to ask how to make Palindrome in Java with 2 methods //Output is Like this

Input a word
Hey
Not a Palindrome
Reverse
yeH

View Replies View Related

Make Own Color To Use With Awt

Aug 22, 2014

I am stuck. I was trying to make my own Color to use with awt.

I used the statement :

public static final Color purple = new Color(255,0,255);

When I try to use Color.purple it says it cannot reference purple.

View Replies View Related

How To Make And Use A List

Nov 3, 2014

I first learned how to program with BYOB. In BYOB there were variables and lists. Variables worked the same as Java and lists were groups of variables. To create a list, I would give it a name. I could then add variables to this list as items throughout the program. Here's an example of what a list would look like:

[[List]]
item 1: Hello
item 2: world

I could then call upon item 1 or item 2 and delete them if needed. In Java, I want to have 3 lists of variables into which I put user input as variables. The code would look something like the following: (stuff with "//" at the end is detailing what I want to do, not actual working code)

import java.util.*;
public class Archives {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

[code]....

View Replies View Related

How To Make Loop End

Feb 3, 2014

I do not know how to make the loop end. I think there is an issue with my second and thrid algorithms..Also its a commission calculator

--- Update ---

//Start Program
package commission;
import java.util.Scanner;
public class Commission
{

private static boolean saleTargetrange;

[code]....

View Replies View Related

How To Make Square Which Is Filled With (dot)

Oct 17, 2014

Do I want to make something like this:

*****
*.....*
*.....*
*.....*
*****

I am stuck, I have made a code that creates this and don't know how to complete it.

*****
* *
* *
* *
*****

Code:

class Main {
public static void main( String args[] ) {
System.out.print("#Enter number of stars :");
int stars = BIO.getInt();

[Code] ....

View Replies View Related

Using Text File To Make GUI?

Apr 16, 2015

I am currently in the progress of making a GUI for a project. I am trying to make a maze and I need it displayed in a GUI. So, I thought I would be able to do that with a text file that I created. The code I have for it so far runs and compiles but it is not displaying my text file as a GUI, even though it reads the file. All I get are a bunch of green rectangles. I am using Netbeans to code this

package rectangles;
import java.awt.Color;
import java.awt.Graphics;//this will draw the maze
import java.awt.Graphics2D;//
import java.io.BufferedReader;
import java.io.FileNotFoundException;//handles file

[code]....

View Replies View Related

Why Add Static To Make A Constant

Oct 30, 2014

public static final String NAME="JAVATAR";

"final" makes sure the constant has the same value and prevents it from being changed. So why add "static" to make it a constant. I figured the reason a few weeks back but don't remember it now.

View Replies View Related

Make A Pause Between Every Loop

Feb 18, 2015

I've been learning Java in school for lika a year now. Our teacher wanted us to make a game called "Game of Life" .Now it's not very optimized because the only type of GUI we know how to make it with JButtons so if I want a 100x100 grid that means the program has to load 10000 buttons and change text and color on them which I can imagen cause lags and so on but if we ignore that lagg our teacher wanted us to make it loop-able and well I kinda succeeded but the only problem is that I can't get it to wait between every loop so if I tell the program to loop 100 times, the program processes that and that takes forever and then updates the board and sometimes it takes forever and sometimes you cant even see the "cells" moving. Is it possible to get my program to loop and if so how? Here is the code:

//------------------------------------------------------------------------------------------------------------------------
// Hamta standardpaket
//------------------------------------------------------------------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

[code]....

View Replies View Related

Make A Switch With A String

Jan 9, 2015

I needed to make a switch with a string ,but eclipse told met there was an error and that the fix was to switch to 1.7 compliant. I did so and now when i run my program errors come back.

Here are the errors :

Exception in thread "main" java.lang.UnsupportedClassVersionerror: start : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)

[code]....

View Replies View Related

How To Make JPanels Slide

Sep 25, 2014

I want to know how can I make a JPanel slide to to another JPanel (Slowly move to the next). I've made multiple JPanels so when I click on next it will take me to the next panel. Now I just need to add a nice transition to make my program look nicer. Is there an easy way to do it? or any way is fine I just want to add a transition ....

View Replies View Related

Trying To Make The Image Move

Oct 27, 2014

I am having trouble making my image move to a certain position in a certain amount of time which is set inside a text file. I was wondering what I'm doing wrong and what I'm missing.

import java.io.*;
import java.util.*;
import java.io.FileReader;
public class Animator {
EZImage HP;

[code]....

View Replies View Related

How To Make Smoother Movement

Jan 23, 2014

First, I have a figure that moves around the screen. It uses keylisteners and just subtracts or adds pixels. However, I notice the movement is not smooth at all. It is very rigid and laggy movement. How can I make it smoother movement?

Second, you get three lives in the game. The lives are subtracting correctly, but I want the game to say "GAME OVER" on a dialog box. How would I get this to happen? My JFrame and my life int are in separate classes. I know I should use an if statement, saying if lives are at or less than zero, open the box, but how do I open the box?

Third, I want to display the time on the screen. I have a swing timer, but how do I put it on the screen? DrawString is not working for me.

Fourth, I want to set an icon for the game, the code is running, but not doing anything.

Java Code: frame.setIconImage(Toolkit.getDefaultToolkit().getImage("/Users/MW/Downloads/petericon.jpg")); mh_sh_highlight_all('java');

View Replies View Related

How To Make The Score Appear In The JFrame

Mar 28, 2014

I was thinking to make a game where a button is appearing in random spots and you have to click it, and once you click it you're score goes up. But I don't know how to make the score appear in the JFrame, and I want the score to update everytime the Button is Clicked.

Here is the code:

Java Code:

package clickmegame;
import java.awt.Dimension;
import java.util.Random;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ClickMeGame {
public static void main(String[] args) {

[Code]...

View Replies View Related

How To Make Pseudo Animation

Jan 24, 2014

I have an image that moves with arrow keys, and I want to make it appear to be moving. So, I made that image, and then another with the legs moved, to give the illusion of motion. I added it to an event

Java Code:

if (k == KeyEvent.VK_RIGHT) {
image1 = image6;
peterx = peterx + 10;
resetIt();
repaint();
} mh_sh_highlight_all('java');

But it only serves to change it once. How would I make it revert to the original frame once it is converted to the second frame (image 6)? I tried a gif but to no avail?

View Replies View Related

How To Make Calculator Using Stacks

Feb 5, 2014

I got to make a java code for my class. I must make a calculator using stacks. I have a code but i got some mistakes. Here is the code

Java Code:

package stackscalc;
import java.util.Scanner;
import java.util.Stack;
import java.util.EmptyStackException;
class Arithmetic {
int length;
Stack stk;
String exp,

[Code] .....

View Replies View Related

Make A Program With Two Buttons

Feb 10, 2014

I'm trying to make a program with two buttons... when you click the first a label shows a red square when you click the second it shows a green square... right now i have the imageicons as a comment because when they weren't a comment and i ran the program i saw nothing... the same thing happens when i add label2 to panel3.

Java Code:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GUI3{
public static void main(String[] args){
//frame
JFrame frame = new JFrame("Test");

[code]...

View Replies View Related







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