Are you using a version of Windows or Mac on BlueJay? In any case, I will go over the Mac version and hope it works.
Create a new class and enter Person as the class.
Open the editor window by right-clicking on the class and clicking "Open Editor".
Your class should have the following format.
public class Person {
}
The first requirement you have indicated is
- Its constructor takes 3 parameters, two strings containing first and last names, and an int representing age
What have you done well with the code
public Person(String firstName, String lastName, int age)
So there are no changes .: D
NOT
public Person(String first, String last, int age)
[We could use this instead, but donโt confuse ourselves, it seems the person wanted you to use the first one)
Although we want this class to receive these 3 parameters, so we need 1) have private variables to store these values โโ2) assign them inside the constructor.
Looking back at what BlueJ gave with these lines
We want to put in your constructor change and additional changes 1) and 2)
Okay, just breathe and watch. We have two sets of each variable !!! Well, one for the class, and the other is what comes with the constructor. To explain everything, there are too many lines now :(, so you will need to read the Java book. [Only the first few chapters ... read it, watching season 1 of 24], most books come with this example of the Person class.
Well, so killed the first call. Let's look at the second one.
-its getName method has no parameters and returns a string with the format "Lastname, Firstname"
Therefore, his method will go on to this section for brevity.
http://java.sun.com/docs/books/tutorial/java/javaOO/methods.html
This will explain it much better if I do it. Ok, I'll give you some time.
Did you read? Not? Go read this Grr! :( Important
So, now that you have done what the following should make sense to you.
/** * The getName Method - put in a little description here * * @return the String with the format "Lastname, Firstname" */ public String getName() { // put your code here // I did and this is called string concatenation in java // Google it:"string concatenation in java" return this.lastName + ", " + this.firstName; }
So, I made a method similar to the one made by BlueJ, and it looked like this. It gets names (this.lastName and this.firstName NOT lastName and firstName, which will work, but don't confuse yourself with k?)
Full code with BlueJ
public class Person {
}
Are you following this right path? Like? If you did not know anything about coding, variables, data types and methods, I would say that this was a fair assumption:) ... but you really should read the Java Intro book.
The right program? naw ... This BlueJ program is weird.
Google for "NetBeans" is free.
Itโs good that breakfast on the West Coast has passed.