Jump to content

Help with basic Java

Audiopunx

I'm about to go all noob,but I really need help. It's a Caeser cipher project, and though I have most of it done(not really like a fourth)I really don't know how to put it all together.Heres  what I have done so far. http://pastebin.com/7Mb6u94x

Link to comment
Share on other sites

Link to post
Share on other sites

This looks like it could have helped me last year with a lot of my algebra homework! What about it is not working. It seems to asks if it should decrypt or encipher, then goes on to ask shift and words. Is your problem is actually executing the shift? Cause I would recommend writing more helper methods for, like one that switches enciphered character with deciphered one, just to clean things up. I am confused on what you mean by put it all together cause it seem somewhat together to me, but I am just a hs student in ap java doing similar code!

Desk: monitors 3x Asus VE248h(eyefinity), Keyboard Cm Strom Trigger(mx red), Mouse Corsair m65, Headset Audio Technica ATH-M50

Black Friday 2013 Build: i7 4770k, Gigabyte Z87X UD5H, 16gb Corsair, Msi R9 290, Corsair Axi 760, Corsair 750D, 2x intel 530 240gb ssd, 2x Seagate 400gb

Older Machine amd x640, msi 760g mobo, 8gb gskillz, Sapphire 6870, Corsair hx650, Cooler master haf 922, ocz agility 3 120gb ssd || HTPC: i7 3770k, shuttle xpc z77, 16gb gskillz, Asus GTX 650 ti, intel 120gb msata ssd

Link to comment
Share on other sites

Link to post
Share on other sites

This looks like it could have helped me last year with a lot of my algebra homework! What about it is not working. It seems to asks if it should decrypt or encipher, then goes on to ask shift and words. Is your problem is actually executing the shift? Cause I would recommend writing more helper methods for, like one that switches enciphered character with deciphered one, just to clean things up. I am confused on what you mean by put it all together cause it seem somewhat together to me, but I am just a hs student in ap java doing similar code!

I know the original post doesn't really make sense,but basically my teacher wants us to do everything in different methods.One for creating shifted alphabet, one for encrypting letter,and one for encrypting message.The thing is I actually have no idea how to use these public char[] arrays, like how do I use one for another?

Link to comment
Share on other sites

Link to post
Share on other sites

Right now I am learning all about sorting methods, but I have not done anything with char arrays, but I think they function the same as a String, int, or any other class array. I normally do it where I have sub methods that I call ie:  ArrayList<Integer> trimmed = RemoveLowQuizGrades(a);

 public static ArrayList<Integer> RemoveLowQuizGrades(ArrayList<Integer> untrimmed){

     Code n stuff

     return untrimmed;

}

and that way it is out of the main code. I have not dealt with global variables, I have done stuff like that, where "a" is the array of quiz grades that I need to the lowest scores removed. Instead of writing it in the main method I wrote a helper one that made it cleaner. When I declare it, I make it need a array given to it when it is called, and I named that array untrimmed, same thing as "a", which become the trimmed version. I am not sure if this helps. 

Desk: monitors 3x Asus VE248h(eyefinity), Keyboard Cm Strom Trigger(mx red), Mouse Corsair m65, Headset Audio Technica ATH-M50

Black Friday 2013 Build: i7 4770k, Gigabyte Z87X UD5H, 16gb Corsair, Msi R9 290, Corsair Axi 760, Corsair 750D, 2x intel 530 240gb ssd, 2x Seagate 400gb

Older Machine amd x640, msi 760g mobo, 8gb gskillz, Sapphire 6870, Corsair hx650, Cooler master haf 922, ocz agility 3 120gb ssd || HTPC: i7 3770k, shuttle xpc z77, 16gb gskillz, Asus GTX 650 ti, intel 120gb msata ssd

Link to comment
Share on other sites

Link to post
Share on other sites

Right now I am learning all about sorting methods, but I have not done anything with char arrays, but I think they function the same as a String, int, or any other class array. I normally do it where I have sub methods that I call ie:  ArrayList<Integer> trimmed = RemoveLowQuizGrades(a);

 public static ArrayList<Integer> RemoveLowQuizGrades(ArrayList<Integer> untrimmed){

     Code n stuff

     return untrimmed;

}

and that way it is out of the main code. I have not dealt with global variables, I have done stuff like that, where "a" is the array of quiz grades that I need to the lowest scores removed. Instead of writing it in the main method I wrote a helper one that made it cleaner. When I declare it, I make it need a array given to it when it is called, and I named that array untrimmed, same thing as "a", which become the trimmed version. I am not sure if this helps. 

Yeah it's cause I have all this code in it, but i'm not really sure how to actualize it in main method, right now it is just sitting there not doing anything.

Link to comment
Share on other sites

Link to post
Share on other sites

blabal = encryptletter(shift, message);

 

that would be how u call it, if you put that in your main method it will run the sub method with the arguments that you give it, in this case the shift and the message.

Desk: monitors 3x Asus VE248h(eyefinity), Keyboard Cm Strom Trigger(mx red), Mouse Corsair m65, Headset Audio Technica ATH-M50

Black Friday 2013 Build: i7 4770k, Gigabyte Z87X UD5H, 16gb Corsair, Msi R9 290, Corsair Axi 760, Corsair 750D, 2x intel 530 240gb ssd, 2x Seagate 400gb

Older Machine amd x640, msi 760g mobo, 8gb gskillz, Sapphire 6870, Corsair hx650, Cooler master haf 922, ocz agility 3 120gb ssd || HTPC: i7 3770k, shuttle xpc z77, 16gb gskillz, Asus GTX 650 ti, intel 120gb msata ssd

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×