1
00:00:00,410 --> 00:00:03,830
In this video, I'm going to cover part one of the vending machine application.

2
00:00:05,180 --> 00:00:10,490
The first task was to add the necessary fields to the item class, and if you look back at the requirements,

3
00:00:10,490 --> 00:00:13,070
the fields are private string name.

4
00:00:16,990 --> 00:00:18,880
Private double price.

5
00:00:23,490 --> 00:00:26,010
And private int quantity.

6
00:00:29,450 --> 00:00:33,800
All right, now, remember that if a class is fields, you need to apply the big three steps.

7
00:00:34,250 --> 00:00:39,110
We need to take instructor getters and setters and the constructor is going to be public.

8
00:00:43,820 --> 00:00:47,480
It's going to take as many parameters as there are fields, so three.

9
00:00:54,820 --> 00:01:00,640
And the constructor runs when you create a new object, so we're going to set every field in that object

10
00:01:00,640 --> 00:01:02,320
equal to a parameter value.

11
00:01:21,910 --> 00:01:27,520
All right, simple enough, and now we can use Intellisense to autocomplete, the getters and setters.

12
00:01:46,700 --> 00:01:51,470
Now, Task three told us to add a copy constructor because at some point we're going to need a way to

13
00:01:51,470 --> 00:01:56,930
copy Eitam objects without falling into the trap so we can simply copy this constructor.

14
00:01:59,690 --> 00:02:03,740
And instead of parameters, we're going to be obtaining values from a source object.

15
00:02:10,300 --> 00:02:15,130
And then we're just going to set every field in the current object equal to the field value from a source

16
00:02:15,130 --> 00:02:15,820
object.

17
00:02:29,060 --> 00:02:33,650
All right, and now task force tells us that every class that models an object should have a two string

18
00:02:33,650 --> 00:02:34,050
method.

19
00:02:34,340 --> 00:02:36,680
So we're going to add it to three methods, our class.

20
00:02:50,810 --> 00:02:52,970
And copy over the format.

21
00:03:04,400 --> 00:03:06,920
And will replace the placeholders where we need to.

22
00:03:10,830 --> 00:03:11,790
This name.

23
00:03:20,930 --> 00:03:21,620
Colin.

24
00:03:24,310 --> 00:03:25,540
The stock price.

25
00:03:32,300 --> 00:03:35,300
Put a space here where they put a bracket.

26
00:03:36,200 --> 00:03:39,230
Embed the quantity inside of another Brackett's.

27
00:03:54,750 --> 00:03:57,150
All right, we're done creating the item class.

28
00:04:00,120 --> 00:04:01,050
So inside main.

29
00:04:04,050 --> 00:04:06,540
I'm going to create a new object of the item class.

30
00:04:11,850 --> 00:04:16,019
I'm going to pass in an item named Pepsi worth three ninety nine.

31
00:04:18,600 --> 00:04:21,720
And there is going to be three Pepsis inside the vending machine.

32
00:04:24,130 --> 00:04:26,050
All right, and we can print the object.

33
00:04:39,740 --> 00:04:40,580
Run the code.

34
00:04:54,410 --> 00:04:56,300
And everything works beautifully.

