Java Constructors?

Alright I'm stuck on 4 & 5 haven't started 6 yet. Not looking for anybody to do them just would like some help on finishing up 4 & 5 and possibly give any feedback on the code so far.

2 .Create Instance Variables (attributes) Create at least 3 private instance fields (attributes) for your class You must use at least 3 different data types for your fields3. Create getter (accessor) and setter (mutator) methods Create a getter (accessor) method for each of your instance variables Create a setter (mutator) method for each of your instance variables 4. Create a Method to display your data Create a method called display, that simply prints out the values of all instance variables of your object5. Create 2 Constructors Create a default constructor (no parameters) that assigns all your instance variables to default values Create a parameterized constructor that takes all instance variables as parameters, and sets the instance variables to the values provided by the parameters 6. Testing your program Create a class called Demo.java. This class will contain your main method Create an instance of your class by using the default constructor. Call all your objects set methods to assign values to your object Call the objects display method, to print out it's values Create another instance of your class by using the parameterized constructor Call the objects display method, to print out it's values

// prints out the values of all instance variables of your object public void display() { System.out.println(brand); System.out.println(color); System.out.println(size);

}

}

This is my Demo class that I'm stuck with. Am i supposed to get input or put the values myself? Also how do I "Call the objects display method, to print out it's values"? Please any help would be appreciated.

Text in java is known as a String. Strings are always surrounded by quotes " " . You can combine variables and strings at any time!

You can do things like this:

System.out.println("You have " + sugar + " sugar in your cup");

Let's say sugar is equal to 5.

The output would be: You have 5 sugar in your cup

.

Extra:

Here is another way to set values in a constructor

public Coffee(double sugar, int milk, boolean heat) {

this.sugar = sugar; this.milk = milk; this.heat = heat;

}

Basically, the names of the variables in the parameters are the same as the ones in our Coffee class. In order to distinguish between them, we can use "this".

What "this" means is that it will refer to the variables from the class, and not the ones within the method. To further understand what I mean, copy and past the constructor I made. Click on sugar (the one with "this" on it.), you will see that it will be highlighted, as well as the ones all over the class. Now remove the this part (make this.sugar into sugar). Now click on it again. You will see that it only highlights the sugar variable inside of the method.