10.3 Java Helsinki Uni MOOC programming 1 part 2! Methods Part 3 of 3

preview_player
Показать описание
This is part 3 of the Methods section and in this tutorial, we work the next few challenges, including Smallest, Greatest, Averaging, Star sign and Advanced astrology.

0:00 Intro
0:53 Smallest challenge
02:40 Greatest challenge
05:50 Averaging challenge
09:27 Execution of Method Calls and the Call Stack
12:33 Call Stack and Method Parameters
17:15 Method Calling Another Method
19:46 Star sign challenge (Part 1 of 4 - Printing stars)
22:15 Star sign challenge (Part 2 of 4 - Printing a square)
24:22 Star sign challenge (Part 3 of 4 - Printing a rectangle)
26:05 Star sign challenge (Part 4 of 4 - Printing a triangle)
28:26 Advanced astrology challenge (Part 1 of 3 - Printing stars and spaces)
31:46 Advanced astrology challenge (Part 2 of 3 - Printing stars and spaces)
33:25 Advanced astrology challenge (Part 3 of 3 - Printing stars and spaces)
37:00 Outro

Remember to keep practising and trying new things and happy coding! If you like the video, please give it a thumbs up and subscribe.
Рекомендации по теме
Комментарии
Автор

If there's anyone out there strugling with the printTriangle method, it's actually like so:
public static void printTriangle(int size) {
for (int i = 1; i <= size; i++) {
printSpaces(size - i);
printStars(i);
}
}
It's size - i, not minus 1.

usoppgostoso
Автор

Oh wow that Xmas tree was a doozy 🤯. You breezed through that with no problems 😅. Thank you

MrKamakazi
Автор

Thanks so much! Please keep uploading. These videos help a lot

itzeshaan
Автор

Thank you so much I was struggeling with the christmastree

rensspiljard
Автор

I managed to finish and pass the last exercise using 'while' loop.
But man, I'm looking at your solution with 'for' loop now and it looks so much more simple and efficient than mine haha
And thank your for this videos, they're helping a lot

" public static void christmasTree(int height) {
int count = 0;
int test = 1;
while (count < height) {
printSpaces((height - 1) - count);
count++;
printStars (test);
test = test + 2;
}
printSpaces((test-4)/2);
printStars(3);
printSpaces((test-4)/2);
printStars(3);
}"

lucasotaku
Автор

Thanks a lot! Please continue uploading until part 14.

lucrisia_molyneux
Автор

The freaking tree man, If you knew the dumb apporaches I tried before actually realizing that I can substract 1 to multiples of two hahahaha

wholesomeSloth
Автор

Thanks for your video but how did you know that it was height-2 for the Christmas tree at the end of the video?

spyox
Автор

what was your train of thought to do "printStars (2 * i - 1) ??
when I was doing I understand that I would have to use printSpace(height - i) again, but I couldn't reach the same line of thinking of you to end de exercise.

phillipewolff
Автор

I see what you did but I dont understand it. Im not sure if this career is for me.

dblacwell
Автор

Hey duncan i got a doubt, regarding star sign one the thing is i used while loop

So the code is

public static void printStars(int number){
int i = 0 ;
while ( i<number ){
sout(" * ");
i++;
}

So the output is vertical

*
*
*

But i need horizontal ***

So how to achieve this by using while loop

RAJUBHAI-wwem
Автор

man in this part ive been really struggling without your vids like the printStar ( i -1) to get a right angle, i feel like part 3 been bad any recommendations ??

turki-glbt
Автор

This part (method calling another method) was the hardest one, I just don’t know what’s going on 💀, 2 days and I’m still blank. I didn’t get the multiplication table example and I couldn’t even do the last exercise

MohamedAhmed-rfbk
Автор

25:33, I don’t get why you passed width, how does that end up building a rectangle?

MohamedAhmed-rfbk
Автор

How did that printTriangle() method pass in the last exercise? That was not a right leaning triangle? I cannot get mine to pass.

conlinduffy
Автор

I must thank you for all the hard work, man but i cant figure out the last two Exercise. I'll write a brief explanation on what I understood and what I didnt. I really hope i could get some help if you dont mind

syedtamimhassan
Автор

does anybody know how I can print the Christmas tree from 1 to 5 without multiplying by 2

spyox
Автор

my christmas tree code is scuffed but i made it work lol. what do u think about this:

public static void christmasTree(int height) {
// part 3 of the exercise
int start = 0;
int extraStars = 0;
while (start < height) {
printSpaces(height - start - 1);
start++;
printStars(start + extraStars);
extraStars++;
}
printSpaces(height - 2);
printStars(3);
printSpaces(height - 2);
printStars(3);
}

baliDOTid
visit shbcf.ru