Skip to content

Instantly share code, notes, and snippets.

@tbuehlmann
Forked from anonymous/gist:5262646
Last active December 15, 2015 12:49
Show Gist options
  • Save tbuehlmann/5262795 to your computer and use it in GitHub Desktop.
Save tbuehlmann/5262795 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
class dreizehn4
{
public static void main (String[] args)
{
Scanner in=new Scanner(System.in);
int str=42,life=42,luck=42;
String name;
boolean a=false;
System.out.println("Input name!");
name=in.nextLine();
while(a==false)
{
System.out.println("Input strenght (Int 1-10). Sum of strenght, life and luck may not exceed 15.");
str=in.nextInt();
if(str>=1 && str<=10)
{
a=true;
}
}
a=false;
while(a==false)
{
System.out.println("Input life (Int 1-10). Sum of strenght, life and luck may not exceed 15.");
life=in.nextInt();
if(life>=1 && life<=10)
{
a=true;
}
}
a=false;
while(a==false)
{
System.out.println("Input luck (Int 1-10). Sum of strenght, life and luck may not exceed 15.");
luck=in.nextInt();
if(luck>=1 && luck<=10)
{
a=true;
}
}
if(str+life+luck>15)
{
System.out.println();
System.out.println("You assigned too many points!");
str=5;
life=5;
luck=5;
}
System.out.println();
System.out.println(name+": "+"strenght: "+str+", life: "+life+", luck: "+luck);
}
}
puts 'Input name!'
name = gets.chomp
loop do
puts 'Input strenght (Int 1-10). Sum of strenght, life and luck may not exceed 15.'
@str = gets.chomp.to_i
break if (1..10).include?(@str)
end
loop do
puts 'Input life (Int 1-10). Sum of strenght, life and luck may not exceed 15.'
@life = gets.chomp.to_i
break if (1..10).include?(@life)
end
loop do
puts 'Input luck (Int 1-10). Sum of strenght, life and luck may not exceed 15.'
@luck = gets.chomp.to_i
break if (1..10).include?(@luck)
end
if @str + @life + @luck > 15
puts 'You assigned too many points!'
@str, @life, @luck = 5, 5, 5
end
puts "#{name}: strength: #{@str} life: #{@life} luck: #{@luck}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment