Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Usage Example for: https://splashkit.io/api/text/#is-integer
// Goal: I am reading text and I am printing whether each line is an integer.
// Why: I am showing how to use IsInteger inside a small class.
// Controls: I am typing q or quit to exit.

using SplashKitSDK;

namespace UtilitiesExamples
{
public class IsIntegerRepl
{
public void Run()
{
SplashKit.WriteLine("Is Integer Checker (OOP)");
SplashKit.WriteLine("Type a value and press Enter. Type q to quit.");

bool running = true;
while (running)
{
SplashKit.Write("> ");
string? text = SplashKit.ReadLine();

if (text == null)
{
break;
}

if (text == "q" || text == "quit")
{
running = false;
}
else
{
// I am using IsInteger so I am learning the utility call
if (SplashKit.IsInteger(text))
{
SplashKit.WriteLine("Integer");
}
else
{
SplashKit.WriteLine("Not integer");
}
}
}

SplashKit.WriteLine("Bye");
}

public static void Main()
{
new IsIntegerRepl().Run();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Usage Example for: https://splashkit.io/api/text/#is-integer
// Goal: I am reading text and I am printing whether each line is an integer.
// Why: I am showing how to use is_integer in a simple REPL.
// Controls: I am typing q or quit to exit.

#include "splashkit.h"

int main()
{
write_line("Is Integer Checker");
write_line("Type a value and press Enter. Type q to quit.");

bool running = true;
while (running)
{
write("> ");
string text = read_line();

if (text == "q" || text == "quit")
{
running = false;
}
else
{
// I am using is_integer so I am learning the utility call
if (is_integer(text))
{
write_line("Integer");
}
else
{
write_line("Not integer");
}
}
}

write_line("Bye");
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Usage Example for: https://splashkit.io/api/text/#is-integer
// Goal: I am reading text and I am printing whether each line is an integer.
// Why: I am showing how to use IsInteger in a simple REPL.
// Controls: I am typing q or quit to exit.

using SplashKitSDK;
using static SplashKitSDK.SplashKit;

WriteLine("Is Integer Checker");
WriteLine("Type a value and press Enter. Type q to quit.");

bool running = true;
while (running)
{
Write("> ");
string? text = ReadLine();

if (text == null)
{
break;
}

if (text == "q" || text == "quit")
{
running = false;
}
else
{
// I am using IsInteger so I am learning the utility call
if (IsInteger(text))
{
WriteLine("Integer");
}
else
{
WriteLine("Not integer");
}
}
}

WriteLine("Bye");
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Usage Example for: https://splashkit.io/api/text/#is-integer
# Goal: I am reading text and I am printing whether each line is an integer.
# Why: I am showing how to use an integer check in a simple REPL.
# Controls: I am typing q or quit to exit.

def is_integer_text(s: str) -> bool:
# I am checking if s is an integer (leading +/- allowed)
if not s:
return False
if s[0] in '+-':
s = s[1:]
return s.isdigit()

print("Is Integer Checker (Python)")
print("Type a value and press Enter. Type q to quit.")

while True:
try:
text = input("> ")
except EOFError:
break

if text == "q" or text == "quit":
break

if is_integer_text(text):
print("Integer")
else:
print("Not integer")

print("Bye")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I am reading text lines and I am printing whether each is an integer; I am exiting when I type q.