File size: 1,542 Bytes
4a2a54d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
A category called Nephew is defined in the programme. 
The class has a constructor which receives the following parameters in order:
name (string)
hat colour (string)
height (integer)


Create three objects from the class with the following information:
name: Dewey, hat color: blue
name: Huey, hat colour: green
name: Louie, hat colour: red

All objects have a length of 95.
Save the references of the objects to the variables dewey, huey and louie.






import java.util.Random;

public class Test {
    public static void main(String[] args) {
        System.out.println("Testing object creation...");

        //ADD
        Nephew dewey = new Nephew("Dewey", "blue", 95);
        Nephew huey = new Nephew("Huey", "green", 95);
        Nephew louie = new Nephew("Louie", "red", 95);




        System.out.println("Dewey: " + dewey);
        System.out.println("Huey: " + huey);
        System.out.println("Louie: " + louie);    
    }
}

class Nephew {
    private String name;
    private String hatColor;
    private int height;

    public Nephew(String name, String hatColor, int height) {
        this.name = name;
        this.hatColor = hatColor;
        this.height = height;
    }


    @Override
    public String toString() {
        return "Nephew [name=" + name + ", hat color=" + hatColor + ", height=" + height + "]";
    }
}





Testing object creation...
Dewey: Nephew [name=Dewey, hat color=blue, height=95]
Huey: Nephew [name=Huey, hat color=green, height=95]
Louie: Nephew [name=Louie, hat color=red, height=95]