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

C# Exercise: Vending Machine (OOP, Objects, Classes, Methods)

Create a Console application called “Ch4-Vending“.

Add a class to the application called “VendingMachine“.This class will be composed of one field (i.e., instance variable or attribute) and several methods as follows:

A field of type int called “DepositedAmount“
A constructor that takes no parameters that simply initializes the machine’s DepositedAmount to 0.
A method (no return value) called “DepositCoin” with a single int parameter called “coinAmount”.
This method adds the value passed in the coinAmount parameter to the machine’s DepositedAmount field.
A method (no return value) called “GetDrink” with no parameters
This method does one of two things. If the machine’s DepositedAmount is is sufficient to cover the cost of a drink (75 cents or more), then the method calculates the change (i.e.,DepositedAmount less 75 cents), writes “Your change is {change amount} cents” to the Console, and resets the DepositedAmount back to 0. If the machine’s DepositedAmount is not sufficient (less than 75 cents), it writes “Insert more coins” to the Console.
A method (no return value) called “GetRefund” with no parameters
This method simply displays “You were refunded {refund amount}” (refund amount should be the whole DepositedAmount) to the console and resets the machine’s DepositedAmountback to 0.
Your Main method should create a single instance of your VendingMachine class. You should then call methods on this object to fully test that the machine is functioning properly. No need to get input from the user. Just “hard code” instructions in your Main method.

Learning to code? Follow my C# tutorials for beginners. I do a lot of C# programming challenges and C# projects as part of my homework - every day!
If you are learning to program, nothing beats solving real programming exercises and coding challenges.
So don't forget to subscribe, as I release new programming videos every day!

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «C# Exercise: Vending Machine (OOP, Objects, Classes, Methods)», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

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

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

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