Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2013
    Thanked 0 Times in 0 Posts

    Exclamation combinding codes on java

    I'm decently new to programming, and I made good 2 codes. And the problem is that I want to connect them, but first code is a 'choose your way' type of game, and there's three alternative endings. And the second code I made I want to add to all of the endings. So i was wondering if there is a way that I could write the second code once for all of the endings, instead of writing it for all of them individually. For the first code i used Cases and breaks to split up multiple ways. so the big question is how can I regroup my code after a case statements and a break?
    Last edited by perrinormal; 01-13-2014 at 06:08 AM.

  2. #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Thanked 665 Times in 660 Posts
    without seeing anything else, it sounds like it might make sense to put the common ending into a function and then call that function at the end of each of the three endings

  3. #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,699 Times in 2,675 Posts
    combinding codes on java

    This is the JavaScript forum. Be aware that Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts