Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: I'm stuck on my Camelot game

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation I'm stuck on my Camelot game

    I'm completely lost, and this is due Monday, March 12th. I've been working on the User class and my setters, getters, and constructor are never happy I've attached my progress so far. If somebody could do just ONE of the Animated subclasses (user, knight, or peasant) i would greatly appreciate it. [I'm using Eclipse (Helios) btw.
    Thank you - stagnit.

    I suggest you check the java docs for this game here: Javadoc documents for Camelot

    Below are the instructions to my assignment:


    You will implement the classes shown in in the figure, along with a Game class which holds the board description. The specific methods that each class will implement are explained in detail in the Javadoc documents for Camelot (which you must read and follow). Notice that the documentation tells you exactly which methods and which properties you need to implement for every class. The Animated class has a protected enum Direction {N,S,E,W}; which shows up as Animated.Direction in the javadocs.

    The program will have a main in the Game class which looks like this:
    Public static void main(String[] args) {
        Scanner keyboard = new Scanner(System.in);
        Game g = new Game();
        g.add(new Sword(3,3));
        User user = new User(1,4);
        g.add(user);
        g.add(new Knight(5,5));
        g.add(new Peasant(9,5));
        g.add(new Peasant(6,7));
        g.add(new Peasant(4,8));
        g.add(new Peasant(7,2));
        g.add(new Peasant(3,5));
        String command = "";
        do {
          System.out.println(g); //print out the game board
          System.out.print("Your move:");
          command = keyboard.next();
          user.move(command); //move the user
          g.moveAll(); //move everyone
          g.resolveConflicts(); //resolve any conflicts between those in the same row,col
        } while (user.isAlive());
     }

    A sample run of the program looks like:

    __________
    ____Y_____
    __________
    ___S_P____
    ________P_
    _____K____
    _______P__
    __P_______
    __________
    _____P____

    Your move:south
    Knight moves S
    Peasant moves E
    Peasant too weak to move.
    Peasant too weak to move.
    Peasant too weak to move.
    Peasant too weak to move.
    Peasant too weak to move.
    __________
    __________
    ____Y_____
    ___S_P____
    ________P_
    __________
    _____K_P__
    __P_______
    __________
    ______P___

    Your move:west
    Knight moves W
    Peasant moves S
    Peasant too weak to move.
    Peasant moves E
    Peasant too weak to move.
    Peasant moves N
    Peasant too weak to move.
    Peasant too weak to move.
    Peasant too weak to move.
    ______P___
    __________
    ___Y______
    ___S_P__P_
    __________
    __________
    ____K___P_
    __P_______
    __________
    __________

    Your move:south
    Knight moves W
    Peasant moves N
    Peasant too weak to move.
    Peasant moves S
    Peasant too weak to move.
    Peasant too weak to move.
    Peasant moves E
    Peasant too weak to move.
    Peasant moves E
    Peasant too weak to move.
    User picks up Sword
    __________
    __________
    __________
    ___Y__P_P_
    __________
    __________
    ___K______
    ___P____P_
    __________
    ______P___

    Your move:east
    Knight moves W
    Peasant too weak to move.
    Peasant too weak to move.
    Peasant moves E
    Peasant too weak to move.
    Peasant moves W
    Peasant too weak to move.
    Peasant too weak to move.
    __________
    __________
    __________
    ____Y_P__P
    __________
    __________
    __K_______
    __P_____P_
    __________
    ______P___

    Your move:east
    Knight moves S
    Peasant too weak to move.
    Peasant moves S
    Peasant too weak to move.
    Peasant moves W
    Peasant too weak to move.
    Peasant too weak to move.
    Peasant moves S
    Peasant too weak to move.
    Bloodthristy Knight kills a P
    __________
    __________
    __________
    _____Y__P_
    ______P___
    __________
    __________
    __K_______
    ________P_
    ______P___

    Your move:south
    Knight moves W
    Peasant moves W
    Peasant too weak to move.
    Peasant moves W
    Peasant too weak to move.
    Peasant moves N
    Peasant too weak to move.
    Peasant moves S
    Peasant too weak to move.
    __________
    __________
    ________P_
    __________
    _____Y____
    ______P___
    __________
    _K________
    _______P__
    _____P____

    Your move:quit
    Knight moves W
    Peasant moves E
    Peasant too weak to move.
    Peasant moves S
    Peasant too weak to move.
    Peasant moves S
    Peasant too weak to move.
    Peasant too weak to move.


    Basically, the user tells the User how to move (N,S,E,W). The knights move randomly (one of N,S,E,W) on each turn. The peasants flip a coin, if heads they stay put otherwise they move randomly (one ofN,S,E,W). The world is 10 by 10 and wraps around.

    The resolveconflicts method is described in the javadocs. It goes over every Thing. If there is another Thing in the same row,col position then, if the Thing is a Knight it kills (removes) any Thing else there. If it is the user then if it finds the sword there it picks it up (thus killing it) and it is it a peasant it kills it.

    I recommend you implement this program in the following order:
    1. The Thing hierarchy, start at the top and work your way down. Start with the properties, then the toString() methods, then the move() methods.
    2. The Game class, its properties and constructor.
    3. Game.toString(), test it.
    4. Game.add()
    5. Game.remove()
    6. Game.thingsAt()
    7. Game.moveAll(): this should just call move() on every thing.
    8. Finally, Game.removeConflicts()
    Attached Files Attached Files
    Last edited by Stagnit; March 9th, 2012 at 11:46 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: I'm stuck on my Camelot game


  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I'm stuck on my Camelot game

    Quote Originally Posted by Norm View Post
    yeah...thanks?? I really need help with this

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: I'm stuck on my Camelot game

    Please explain and ask some specific questions about it.

  5. #5
    Junior Member
    Join Date
    Mar 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I'm stuck on my Camelot game

    All i'm asking is for someone to download my work so far, and complete either User, Knight, or Peasant class. I should be able to do the rest. I would greatly appreciate it.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: I'm stuck on my Camelot game

    Post your questions here.

  7. #7
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: I'm stuck on my Camelot game

    You can't honestly think that what you're asking is at all reasonable? Stop being so lazy and put some effort into it.
    Work on it yourself and come back to us when you've encountered a programming error, and when you do, post a full stack trace of the exception accompanied by the relevant code posted on this page.

    Quote Originally Posted by Stagnit View Post
    yeah...thanks?? I really need help with this
    He was doing what you should have done, so less of the patronising.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

Similar Threads

  1. Simple game that requires me to load game settings from a file
    By 14fenix in forum Java Theory & Questions
    Replies: 5
    Last Post: December 1st, 2011, 09:21 PM
  2. Help! im stuck!
    By aznguy92 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 15th, 2011, 09:16 PM
  3. Stuck on a few Statements/Questions on timing of Main Game Loop.
    By StevenW in forum Java Theory & Questions
    Replies: 3
    Last Post: July 19th, 2011, 09:20 AM
  4. typing game stuck up
    By chronoz13 in forum AWT / Java Swing
    Replies: 6
    Last Post: April 29th, 2011, 08:09 AM
  5. Problem while programming a simple game of Car moving on a road
    By rojroj in forum Java Theory & Questions
    Replies: 3
    Last Post: April 2nd, 2009, 10:24 AM