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 2 of 2

Thread: strugling to write a method, need some suggestions

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default strugling to write a method, need some suggestions

    i need to add selectWineCase() method to my Browser class which allows a browser to choose a case of wine provided the user is logged into the website. The method is passed a WineCase object as a parameter. so i need to declare a new field wineCase in the Browser class in order to store the case of wine selected. and then i need the selectWinecase() method print a message to a terminal window of the form
    Browser 6732 has selected wine case ref number W1473 of 12 Chablis at £120.

    --- Update ---

    my browser class looks likes this

    private int yearOfBirth;
    private int id;
    private String email;
    private boolean loggedIn = true;

    public Browser(String getEmail, int getId, int getYearOfBirth)
    {
    email = getEmail;
    id = getId;
    yearOfBirth = getYearOfBirth;
    }

    public Browser()
    {
    email = "J.Booth@winedirect.com";
    id = 2678;
    yearOfBirth = 1990;
    loggedIn = true;
    }

    public void yearOfBirth(int getYearOfBirth)
    /**
    *
    */
    {
    yearOfBirth = getYearOfBirth;
    }

    public void id(int getId)
    /**
    *
    */
    {
    id = getId;
    }

    public void setLoggedIn(boolean value)
    {
    loggedIn = value;

    if(loggedIn == true)
    {
    System.out.println("online;" + id);
    }
    else
    {
    System.out.println("Offline");
    }
    }

    public boolean isLoginStatus()
    /**
    *
    */
    {
    return loggedIn;
    }

    public void email(String getEmail)
    /**
    *
    */
    {
    email = getEmail;
    loggedIn = true;
    }

    public void loggedOut()
    /**
    *
    */
    {
    email = "";
    yearOfBirth = 0;
    id = 0;
    loggedIn = false;
    }


    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: strugling to write a method, need some suggestions

    Welcome to the Forum! Please read this topic to learn how to post your code correctly along with other useful info for newcomers. Please fix your post.

    You've outlined what you need, what's preventing you from doing that?

Similar Threads

  1. Replies: 15
    Last Post: May 2nd, 2013, 05:29 AM
  2. how to do write this method with more efficiency ?
    By romavolman in forum Algorithms & Recursion
    Replies: 2
    Last Post: October 2nd, 2012, 11:23 AM
  3. Write a method that searches the BST for a given input
    By Jurgen in forum Algorithms & Recursion
    Replies: 4
    Last Post: January 6th, 2012, 11:46 AM
  4. [SOLVED] Why can't I write to file inside a doGet() method?
    By FailMouse in forum Java Servlet
    Replies: 1
    Last Post: July 7th, 2010, 01:15 AM

Tags for this Thread