Legends of the Jedi Forums Off-Topic Compel being Java learning!
This topic has 8 replies, 5 voices, and was last updated 14 years, 10 months ago by Quicksilver.
Viewing 9 posts - 1 through 9 (of 9 total)
    • Compel Bast Member
      April 23, 2009 at 9:55 am #1057

      [code:3i7ektj2]public class Fighter {
      public int F; // fight value – bonus to hit roll
      public int S; // strength value – bonus to wound roll
      public int T; // toughness value – minus to getting wounded
      public int A; // attack value – number of attacks
      public int W; // wounds value – ability to be wounded

      public String toString() {
      return ("| |F: " + F + " |S: " + S + " |T: " + T + " |A: " + A + " |W: " + W + " | | ");
      }
      }[/code:3i7ektj2]

      [code:3i7ektj2]public class Battle {
      public static void main(String[] args) {
      Fighter Bob = new Fighter();
      Fighter Jim = new Fighter();

      Bob.F = 5;
      Bob.S = 3;
      Bob.T = 6;
      Bob.W = 4;
      Bob.A = 2;

      Jim.F = 4;
      Jim.S = 4;
      Jim.T = 4;
      Jim.W = 6;
      Jim.A = 3;

      System.out.println( "Bob’s starting stats are " + Bob);
      System.out.println( "Jim’s starting stats are " + Jim);
      System.out.println("");
      System.out.println("");
      System.out.println(" Bob’s starting wounds are " + Bob.W);
      System.out.println(" Jim’s starting wounds are " + Jim.W);
      System.out.println("");
      System.out.println("");
      //Rolling to hit for player 1 (Bob).

      //

      do {

      for (int i =1; i <= Bob.A; i++ ) {
      int hitroll1 = (int)(Math.random()*6) + 1 + Bob.F;

      System.out.println("Bob’s roll to hit: " + hitroll1 + ". He needed 7.");
      if ( hitroll1 >= 7 ) {
      System.out.println("Bob strikes his opponent!");
      int woundroll1 = (int)(Math.random()*6) + 1 + Bob.S – Jim.T;
      System.out.println("Bob’s roll to wound: " + woundroll1 + ". He needed 4.");

      if ( woundroll1 >= 4 ) {
      System.out.println("Bob WOUNDS his opponent!!! ");
      int jimwounded = Jim.W – 1;
      Jim.W = jimwounded;
      System.out.println("Jim’s wounds: " + Jim.W + " left!");
      }

      else{
      System.out.println("Bob has failed to wound! ");
      }
      }
      else{
      System.out.println("Bob misses his opponent!");
      }
      }
      for (int i =1; i <= Jim.A; i++ ) {

      int hitroll2 = (int)(Math.random()*6) + 1 + Jim.F;

      System.out.println("Jim’s roll to hit: " + hitroll2 + ". He needed 7.");
      if ( hitroll2 >= 7 ) {
      System.out.println("Jim strikes his opponent!");
      int woundroll2 = (int)(Math.random()*6) + 1 + Jim.S – Bob.T;
      System.out.println("Jim’s roll to wound: " + woundroll2 + ". He needed 4.");

      if ( woundroll2 >= 4 ) {
      System.out.println("Jim WOUNDS his opponent!!! ");
      int bobwounded = Bob.W – 1;
      Bob.W = bobwounded;
      System.out.println("Bob’s wounds: " + Bob.W + " left!");
      }

      else{
      System.out.println("Jim has failed to wound! ");
      }
      }
      else{
      System.out.println("Jim misses his opponent!");
      }

      }
      System.out.println("");
      System.out.println(" Bob: " + Bob.W + " Jim: " + Jim.W);
      System.out.println("");
      System.out.println("NEW ROUND!");
      System.out.println("");
      } while (( Jim.W > 0 ) && ( Bob.W > 0 ));

      if ( 0 >= Jim.W ) {
      System.out.println("Jim is unconscious!");
      }

      if ( 0 >= Bob.W ) {
      System.out.println("Bob is unconscious!");
      }

      }
      }
      [/code:3i7ektj2]

      Yeah, I’m a bit lonely. Anyways, here’s what I’ve been playing with in my course!

    • Rojan QDel Member
      April 23, 2009 at 1:09 pm #9829

      Heh, I’m taking a Java course too! I didn’t know you were.

    • Compel Bast Member
      April 23, 2009 at 1:31 pm #9830

      Aye, I’ve been sent on a 5 day java course (there’s a note in imm command about it) and well, it’s day 4 and I’m really wanting to go home now. We’re now onto serialisation and stuff like that and yeah… too much info.

    • Rojan QDel Member
      April 23, 2009 at 2:07 pm #9831

      Java is easy! Its one of the best documented languages out there.

    • Compel Bast Member
      April 24, 2009 at 12:23 pm #9838

      Aye, maybe for someone with practical programming experience.

      I mean, I can do a bit of it now (as seen by my pretty fight program).

      But still, I really do prefer my vb.net. Gotta love just dragging and dropping windows, buttons and all sorts like that with the ease that’s just the same as making a msword textbox!

    • Drel Member
      May 3, 2009 at 1:57 am #9880

      Java isn’t that difficult.
      You just need a coffee maker, some coffee, maybe some milk/sugar/whatever…

    • Ilyena Participant
      June 14, 2009 at 11:24 am #10096
      "Compel Bast":10q2xa58 wrote:
      Aye, maybe for someone with practical programming experience.

      I mean, I can do a bit of it now (as seen by my pretty fight program).

      But still, I really do prefer my vb.net. Gotta love just dragging and dropping windows, buttons and all sorts like that with the ease that’s just the same as making a msword textbox![/quote:10q2xa58]

      Get NetBeans. That does exactly the same as VB, just in Java. You can create GUIs really easily.

    • Quicksilver Participant
      June 14, 2009 at 2:46 pm #10106

      :

      I am sad that I comprehend you. Also that I had to learn Unix.

Viewing 9 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic.