Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By Fubarable

Thread: I'm stuck on my Camelot game

  1. #1
    stagnit is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default 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 You can download my progress so far here: Camelot.zip 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:


    I'm stuck on my Camelot game-camelotumlclassdiagram.png
    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:
    Java Code:
    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()

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: I'm stuck on my Camelot game

    "I'm completely lost" is not an answerable question other than to suggest that you check out the Java tutorials to gain enough Java knowledge to be able to find yourself. These forums work much better if you ask a specific question on a specific subject.
    DarrylBurke likes this.

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,401
    Rep Power
    25

    Default Re: I'm stuck on my Camelot game


  4. #4
    stagnit is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Re: I'm stuck on my Camelot game

    Quote Originally Posted by Fubarable View Post
    "I'm completely lost" is not an answerable question other than to suggest that you check out the Java tutorials to gain enough Java knowledge to be able to find yourself. These forums work much better if you ask a specific question on a specific subject.
    i believe i said "my setters, getters, and constructor are never happy"...

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default Re: I'm stuck on my Camelot game

    Quote Originally Posted by stagnit View Post
    i believe i said "my setters, getters, and constructor are never happy"...
    And that's supposed to be an answerable question?

    Have you tried taking them out for dinner? giving them flowers and chocolate? letting them sleep late?
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    stagnit is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Re: I'm stuck on my Camelot game

    Could someone please download what i've done so far and complete ONE of the Animated Subclasses. I would really appreciate it.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: I'm stuck on my Camelot game

    Quote Originally Posted by stagnit View Post
    Could someone please download what i've done so far and complete ONE of the Animated Subclasses. I would really appreciate it.
    While we will be more than happy to answer your questions and try to help you understand programming concepts so that your knowledge can progress and so that you can finish your project, what you are asking is that we do some work for you so that you can turn it in as your own, which no matter how you dress it up is asking us to help you cheat. Please understand that cheating is something that we do not allow nor condone and in fact is something most of us detest. Please do not ask this again or you may be banned from this and other programming forum (understand that many of us moderate at multiple programming fora).

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,401
    Rep Power
    25

    Default Re: I'm stuck on my Camelot game

    If you are having problems with your code, post the code and ask some questions about your problems.

Similar Threads

  1. Stuck, need help please
    By Johnny2009 in forum New To Java
    Replies: 3
    Last Post: 11-03-2011, 10:25 PM
  2. Replies: 3
    Last Post: 10-18-2011, 01:04 AM
  3. Replies: 1
    Last Post: 06-02-2011, 09:29 AM
  4. Replies: 44
    Last Post: 10-19-2009, 08:07 PM
  5. Stuck in sea
    By programmer_007 in forum JDBC
    Replies: 1
    Last Post: 09-17-2009, 04:00 AM

Posting Permissions

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