RUVIDEO
Поделитесь видео 🙏

6.16. (Part 2) Coin Toss Simulator - Java

Starting out with Java: From control structures through objects
Chapter 6
Programming Challenges

16. Coin Toss Simulator

Write a class named Coin. The Coin class should have the following field:
• A String named sideUp. The sideUp field will hold either “heads” or “tails” indicating the side of the coin that is facing up.

The Coin class should have the following methods:
• A no-arg constructor that randomly determines the side of the coin that is facing up (“heads”or“tails”) and initializes
the sideUp field accordingly.
• A void method named toss that simulates the tossing of the coin. When the toss method is called, it randomly
determines the side of the coin that is facing up (“heads” or “tails”) and sets the sideUp field accordingly.
• A method named getSideUp that returns the value of the sideUp field.

Write a program that demonstrates the Coin class. The program should create an instance of the class and display the side that is initially facing up. Then, use a loop to toss the coin 20 times. Each time the coin is tossed, display the side that is facing up. The program should keep count of the number of times heads is facing up and the number of times tails is facing up, and display those values after the loop finishes.

Gaddis, Tony (2015-05-29). Starting Out with Java: From Control Structures through Objects (Page 402). Pearson Education. Kindle Edition.

Learn Java - https://www.youtube.com/playlist?list=PLGFLoZ9w5xCMDOxkwYMQ4jbqisJxdc4Q6

Learn Python - https://www.youtube.com/playlist?list=PLGFLoZ9w5xCNa8Lb6QVlWx7JUoiG3kqkg

Programming challenges, Starting out with Java by Tony Gaddis - https://www.youtube.com/playlist?list=PLGFLoZ9w5xCP2OFHwY6EZq-IIG7JFcdHQ

Programming challenges, Starting out with Python by Tony Gaddis, https://www.youtube.com/playlist?list=PLGFLoZ9w5xCMCvDnylUHIG16hkt90F0sc

Thanks ?

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «6.16. (Part 2) Coin Toss Simulator - Java», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.