Results 1 to 15 of 15

Thread: Database

  1. #1
    ErG
    ErG is offline Member
    Join Date
    Apr 2011
    Posts
    8
    Rep Power
    0

    Default Database

    Hello guys, im new in java, and now i got this project i have to do.
    A local football club wishes to store information on its current squad of players:

    Each Player’s personal information (first name, last name, age, height and weight) should be recorder in a class Person. Each Player’s record for the season should be stored in a class Player. The information stored for each player consists of the number of games played and goals scored. Write a class Goalkeeper which in addition records the number of penalties that the goalkeeper has saved. Provide appropriate methods for accessing this information. You should make appropriate use of inheritance in your solution.

    Information on all Players should be stored in a class Club. Club stores the name of the club and maintains information about all of it's players. Club has methods to add and remove Players addPlayer(Player p) and removePlayer(Player p). It should also contain a method to retrieve a Player’s details given her/his first and last names. (You may assume that no two Players have identical first and last names).

    Where should i start?
    at this point i have only this, but not sure if it works

    Java Code:
    [I]Code Deleted[/I]
    Last edited by ErG; 05-04-2011 at 02:08 PM.

  2. #2
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    you also have this information to keep track of:

    Java Code:
    interface Record {
        //games played
        //goals scored
    }
    
    class Player {
        class PlayerRecord implements Record {
            
        }
    }
    
    class Goalkeeper extends Player {
        class KeeperRecord implements Record {
            //keep shots saved in addition to the other 2
        }
    }

  3. #3
    ErG
    ErG is offline Member
    Join Date
    Apr 2011
    Posts
    8
    Rep Power
    0

    Default

    i made this code for the Person class, tell me if its okey.
    Java Code:
    [I]Code deleted[/I]
    Last edited by ErG; 05-04-2011 at 02:09 PM.

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

    Default

    What is the purpose of this method, and what do you think it does if it is ever called?

    Java Code:
    public void setPersonInfo(){
        this.FirstName = FirstName;
        this.LastName = LastName;
        this.Age = Age;
        this.Height = Height;
        this.Weight = Weight;
    }

  5. #5
    ErG
    ErG is offline Member
    Join Date
    Apr 2011
    Posts
    8
    Rep Power
    0

    Default

    Now that i look i dont need this at all.

  6. #6
    ErG
    ErG is offline Member
    Join Date
    Apr 2011
    Posts
    8
    Rep Power
    0

    Default

    Any tips what should i do next with this project?

  7. #7
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    one tip would be to follow the guidelines regarding naming conventions, class names should be written with an upper-case as the first letter, but not variable names because this makes your code easier to follow.

    class Person {
    String firstName;
    String lastName;
    int age;
    }

    etc... you can read more about that here:
    Code Conventions for the Java Programming Language


    Your instructions state that you should make appropriate use of inheritance, so you do need to make a Goalkeeper class which inherits all of the fields and methods from the player class, and then adds a few more specific to the goal keeper: namely, penalties saved

  8. #8
    ErG
    ErG is offline Member
    Join Date
    Apr 2011
    Posts
    8
    Rep Power
    0

    Default

    Should i use TreeSet for the club class? and if yes how do i use it correctly? any tips?
    Thanks in advance

  9. #9
    ErG
    ErG is offline Member
    Join Date
    Apr 2011
    Posts
    8
    Rep Power
    0

    Default

    I have this club class code that i manage to do
    Java Code:
    import java.util.*;
    import java.util.TreeSet;
    
    public class Club
     {
        public Set<Player> playerSet = new TreeSet<Player>();
       
        public void addPlayer(Player p)
        {
            playerSet.add(p);
        }
        
        public void removePlayer(Player p)
        {
            String firstName = p.getfirstName();
            String lastName =  p.getlastName();
        }
        
        public void printList() 
        {
            Iterator iterator = playerSet.iterator();
            
            while(iterator.hasNext())
            {
                System.out.println(iterator.next().toString());
    
            }
        }
        
        Iterator i = ss.interator();
        while (i.hasNext())
        {
            System.out.println(i.next());
            
        }
    }
    but it dosent work, any help pls
    Last edited by ErG; 05-04-2011 at 02:17 PM.

  10. #10
    ErG
    ErG is offline Member
    Join Date
    Apr 2011
    Posts
    8
    Rep Power
    0

    Default

    and i know that i need to add to the club class add/ remove (Player p) but how do i do it?

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,535
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by ErG View Post
    i made this code for the Person class, tell me if its okey.
    Java Code:
    [I]Code deleted[/I]
    Why are you deleting your own code?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default

    Quote Originally Posted by ErG View Post
    but it dosent work, any help pls
    Which tells us nothing.
    What doesn't work.
    Errors?
    Unexpected output?
    What?

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

  14. #14
    ErG
    ErG is offline Member
    Join Date
    Apr 2011
    Posts
    8
    Rep Power
    0

    Default

    Im deleting my own code because my code will be check around the internet for plagiasarism.

    The code of the club was getting me an error but im working on it whit diferent way, still working cant show you now anything because i dont have anything yet.

  15. #15
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,535
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by ErG View Post
    Im deleting my own code because my code will be check around the internet for plagiasarism.
    Oh dear; maybe they'll make a nuclear bomb detonation mechanism out of it or a Tic Tac Toe game ... you're leaving this thread in a devastated state, i.e. other people reading it won't understand anything from it; don't delete your code from it.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Relational Database or Object Database?
    By mattlindsay in forum New To Java
    Replies: 8
    Last Post: 09-24-2011, 06:44 PM
  2. Database Changes
    By MarkusHendersonicus in forum JDBC
    Replies: 17
    Last Post: 12-27-2010, 05:21 AM
  3. What database shall i use?
    By etherkye in forum JDBC
    Replies: 13
    Last Post: 06-26-2009, 06:03 PM
  4. Replies: 2
    Last Post: 02-11-2009, 04:43 AM
  5. Database in a PDA
    By percivalwcy in forum JDBC
    Replies: 2
    Last Post: 08-08-2007, 03:10 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
  •