#HOW TO WRITE COMPUTER CODE REPEATING CODE#
I think that you see the code as non-duplicated because you know how different it is, but everyone else looks, sees the same name and thinks it's just a standard overload, a bit of syntactic sugar.Still cant get this code to work. Create a text form field that lets you enter text once and have it appear automatically elsewhere in the document, such as the date shown in the file's header. And the fact that none of us can understand what that ArtworkDate field is for suggests that maybe the name of the second method should be changed. Everyone, myself included, who feels it is duplicated is reacting to the method overload, which instinctively should be one method calling another.īut in reality, the second method is doing something very, very different. Return BasketItems.Any(c => c.isInGroup(GroupID, ArtworkDate)) != null įurther Edit: Actually, the further we go down this road, the more I think I see the problem. Answer (1 of 5): I guess you are using python, so the best way irrespective of language will be using While Loop: While True: y int(input(enter no whose table. Public static bool isGroupInBasket(List BasketItems, int GroupID, DateTime? ArtworkDate) Public static bool isGroupInBasket(List BasketItems, int GroupID) / Is a group in the basket already? (do I even need this comment any more?) public bool isInGroup(int GroupID, DateTime? ArtworkDate) I might go further and put an interface on BasketItem so that I can put fake responses on these tests.Īll that said, I wouldn't fail you on a code review for your code, I'd just warn you that if it got more complicated then it would be a problem.Įdit: Actually, reading that back, I've just noticed that it demonstrates the point. or graphical programing elements, rather than writing code using text. Return BasketItems.Any(c => c.isInBasket(GroupID, ArtworkDate)) != null Encouraging students to learn and use official computer science terms will enable. Public static bool isItemInBasket(List BasketItems, int GroupID, DateTime? ArtworkDate) Return isItemInBasket(BasketItems, GroupID, null) Public static bool isItemInBasket(List BasketItems, int GroupID) Select Mathematical Operators from the Subset: drop-down list.
![how to write computer code repeating how to write computer code repeating](https://previews.123rf.com/images/yurich84/yurich841912/yurich84191200011/135898789-programming-with-html-php-and-javascript-backend-source-code-on-computer-monitor.jpg)
On the Insert tab, go to Symbols > Symbol > More Symbols. Then use while True to call it infinitely or for i in range (6) to call it 6 times: import requests def repeat (): addr input () vendor requests.get + addr). This.ArtworkDate = ArtworkDate ? this.ArtworkDate Open up your Word document and place the cursor where you want to insert the Character. Create a function repeat and add your code in it. I would rather see a method on the BasketItem which reads public bool isInBasket(int GroupID, DateTime? ArtworkDate) That could do the trick, however, most of the time you don't even know in advance how many. Notice that the conditional expression appears at the end of the loop, so the statement(s). You can wrap it in a function and call that function as many times as you need to. repeat sum : sum + number number : number - 2 until number 0. This is good style in writing code so it is easy to read, follow, and debug. Notice the format with indents and line spacing. This image should look very similar to what you see on your computer.
![how to write computer code repeating how to write computer code repeating](https://i.ytimg.com/vi/Hw4GEwhCZpc/maxresdefault.jpg)
![how to write computer code repeating how to write computer code repeating](https://i.pinimg.com/originals/a9/5e/f0/a95ef037d1a195fba3afd8b9bb23ad59.jpg)
The first image is the code within the Visual Studio application.
#HOW TO WRITE COMPUTER CODE REPEATING FOR FREE#
I'm not fond of the unit tests you'd have to write. Log in or subscribe for free to enjoy all this course has to offer Imagine you have a block of code you need to repeat multiple times. This is how your program should look like after completing the steps above.