Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Assignment help!!!!

  • 25-02-2008 10:18PM
    #1
    Closed Accounts Posts: 20


    (in java) i have to make an email address in java through an abstract method called makeEmail()
    its has to take first and second names in and take the first letter from the first name followed by a dot, three letters from the second name and then the string @hotmail.co.uk.
    please help if you can


Comments

  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Show us the code you have done so far.


  • Closed Accounts Posts: 20 heavy482


    public abstract class Person
    {
    //Private Variables
    private String firstName;
    private String lastName;
    private int credits;
    private int status;

    //Default Constuctor
    public Person(String first, String last)
    {
    firstName = first;
    lastName = last;
    }

    public int getCredits()
    {
    return credits;
    }

    public void setCredits()
    {
    this.credits=credits;
    }

    public int getStatus()
    {
    return status;
    }


    public String showInitials()
    {


    }

    public abstract String makeEmail();


    }


    public class Student extends Person
    {

    public Student(String firstName, String lastName,int credits,int status)

    //Default Constuctor
    {
    super(firstName,lastName, credits, status);

    }

    public String getStatus()
    {
    return status;
    }

    public void setStatus(int newStatus)
    {
    this.status=newStatus;
    }

    public void addCredits(int additionalPoints)
    {
    credits += additionalPoints;
    }

    public int getCredits()
    {
    return credits;
    }

    public String makeEmail()
    {

    }

    }
    dont have anything for how to show initials.
    THE MAKE EMAIL ONE IS THE PROBLEM BECAUSE OF THE FIRST LETTER AND FIRST 3 LETTERS FROM THE NAMES


  • Registered Users, Registered Users 2 Posts: 1,636 ✭✭✭henbane




  • Closed Accounts Posts: 20 heavy482


    how do i take in a variable in with this or can i ???


  • Registered Users, Registered Users 2 Posts: 26,449 ✭✭✭✭Creamy Goodness


    you don't necessarily take in a variable you can invoke it on a variable and store the result in another variable if you wish like so.


    psuedocode
    String fname
    String fullname = "joe bloggs"
    
    fname = fullname.substring(0,2)
    
    this will place the string "joe" into fname. the 0 is the starting point and the two is where i want to finish, but that's all explained to you in the javadocs link henbane posted.


  • Advertisement
Advertisement