Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code wars: Sign up issue

Tags:

java

Im very new to programming and I recently tried to sign up to code wars. It shows a number of problems, presumably before letting someone sign up.

At the minute I'm stuck on this one:

public class Person{
    String name;

    public Person(String personName){
        name = personName;
    }

    public String greet(String yourName){
        return String.format("Hi %s, my name is %s", yourName, name);
    }
}

Stating Correct this code, so that the greet function returns the expected value.

I can't for the life of me figure out what the problem is. I tried inputing the code into eclipse and there are no errors, so I'm not entirely sure what is required

like image 711
user1738642 Avatar asked Feb 18 '15 14:02

user1738642


1 Answers

I think it wants you to greet someone else.

public class Person{
String name;

public Person(String personName){
    name = personName;
}

public String greet(String yourName){
    return String.format("Hi %s, my name is %s", name, yourName);
}
}

So that the output is

Hi (person), my name is (whatever your name is)

like image 149
Ryanas Avatar answered Sep 28 '22 18:09

Ryanas