Четверг, 16.05.2024, 04:03 | Приветствую Вас Гость

...

Блог


01:31
Задачник по small basic

Задание 1.Доработать так,чтобы второе поле в первое поле тоже копировалось при вводе.
GraphicsWindow.Width = 500
GraphicsWindow.Height = 600
GraphicsWindow.FontSize = 11
GraphicsWindow.Title = "Копирование текстового поля"
GraphicsWindow.BrushColor = "Blue"

Controls.TextTyped = OnTextTyped

Edit_1 = Controls.AddTextBox(0,0)
Controls.SetSize(Edit_1, 250,25)
Edit_2 = Controls.AddTextBox(0,50)
Controls.SetSize(Edit_2, 250,25)

Sub OnTextTyped
edit = Controls.LastTypedTextBox
resulttext = Controls.GetTextBoxText(edit)
COntrols.SetTextBoxText(Edit_2,resulttext)
EndSub


Задание 2.Доработать  так,чтобы генерировался случайный цвет для окна.

GraphicsWindow.BackgroundColor = "SteelBlue"
GraphicsWindow.Title = "Кликни меня"
GraphicsWindow.Width = 320
GraphicsWindow.Height = 200
GraphicsWindow.Show()
GraphicsWindow.MouseDown = OnMouseDown

Sub OnMouseDown
  if Mouse.IsLeftButtonDown Then
  GraphicsWindow.BackgroundColor = GraphicsWindow.GetColorFromRGB(255,0,0) 
  EndIf
EndSub

Задание 3.Доработать так,что все поля очищались по щелчку по кнопке.


GraphicsWindow.Width = 500
GraphicsWindow.Height = 600
GraphicsWindow.FontSize = 11
GraphicsWindow.Title = "Очистить текстовые поля"
GraphicsWindow.BrushColor = "Blue"
Controls.ButtonClicked = OnButtonClick


Edit_1 = Controls.AddTextBox(0,0)
Controls.SetSize(Edit_1, 250,25)
Edit_2 = Controls.AddTextBox(0,50)
Controls.SetSize(Edit_2, 250,25)
COntrols.SetTextBoxText(Edit_1,"текст по умолчанию")
COntrols.SetTextBoxText(Edit_2,"текст по умолчанию")
Button_1 = Controls.AddButton("Очистить все поля ",0,100)

Sub OnButtonClick
  
EndSub

 

Задание 4.Заменить вывод секунд в текстовое поле методом GraphicsWindow.DrawText.

counter_second = 0
GraphicsWindow.Width = 500
GraphicsWindow.Height = 600
GraphicsWindow.FontSize = 11
GraphicsWindow.Title = "Cекундомер"
GraphicsWindow.BrushColor = "Blue"

Timer.Interval = 1000
Timer.Tick = Ontick

Edit_1 = Controls.AddTextBox(100,0)
Controls.SetSize(Edit_1, 300,25)
Controls.SetTextBoxText(Edit_1,"0")

Sub Ontick
counter_second = counter_second + 1
Controls.SetTextBoxText(Edit_1,counter_second)

EndSub

Задание 5.Доработать программу так,чтобы ширина и высота окна случайно менялась по таймеру.

GraphicsWindow.Width = 500
GraphicsWindow.Height = 600
GraphicsWindow.FontSize = 11
GraphicsWindow.Title = "Легкая задача по таймеру"
GraphicsWindow.BrushColor = "Blue"

Timer.Interval = 1000
Timer.Tick = Ontick

Sub Ontick

EndSub


Задание 6.Доработать программу так,чтобы каждые пять секунд кнопка переключала своё состояние видимости пользователю с помощью методов Controls.HideControl и Controls.ShowControl,но если она не нажата,то видимость не меняется.

clicked = 0
state = 0
GraphicsWindow.Width = 500
GraphicsWindow.Height = 600
GraphicsWindow.FontSize = 11
GraphicsWindow.Title = "Переменная состояния"
GraphicsWindow.BrushColor = "Blue"

Button_1 = Controls.AddButton("покажи/скрой меня ", 0,150) 
Controls.SetSize(Button_1, 300,50)
Controls.ButtonClicked = OnButtonClick
Timer.Interval = 2500
Timer.Tick = Ontick

Sub OnButtonClick
  button = Controls.LastClickedButton
  If button = Button_1 Then 
    clicked  = 1
  EndIf
Endsub

Sub Ontick

EndSub

 

Задание 7.Доработать программу так,чтобы файл изображения можно было задавать из текстового поля.
curDir = Program.Directory
ImagePath = curDir+"\mytest.jpg"
TextWindow.WriteLine(ImagePath)
Image = ImageList.LoadImage(ImagePath)
Width = ImageList.GetWidthOfImage(ImagePath)
Height= ImageList.GetHeightOfImage(ImagePath)
if Width > GraphicsWindow.Width  then
GraphicsWindow.DrawText(0,0,"Изображение слишком большое для отображения в этом окне")
ElseIf Height > GraphicsWindow.Height then
GraphicsWindow.DrawText(0,0,"Изображение слишком большое для отображения в этом окне")
EndIf
GraphicsWindow.Width = Width 
GraphicsWindow.Height= Height + 50
GraphicsWindow.DrawImage(Image, 0, 50)

 

Задание 8.Доработать программу так,чтобы изображения текущей директории показывались одно за другим по таймеру.

curDir = Program.Directory
ImagePath = curDir+"\mytest.jpg"
GraphicsWindow.Width = 500
GraphicsWindow.Height = 600
GraphicsWindow.FontSize = 11
GraphicsWindow.Title = "Показ изображений по таймеру"
GraphicsWindow.BrushColor = "Blue"

Timer.Interval = 5000
Timer.Tick = Ontick


Sub Ontick
 
EndSub

Задание 9.Создать графическое окно,на котором будет кнопка,выполняющая запись пути файлов текущий директории в файл,имя этого файла читается из текстового поля.

Sub Find_File()
files = File.GetFiles(Program.Directory)
For i = 1 To Array.GetItemCount(files)
  TextWindow.WriteLine(files[i])
  File.WriteLine("findfiles.txt",i,files[i])
endfor
Endsub

Задание 10 Читать ширину и высоту экрана из файла и устанавливать эти параметры по таймеру.
GraphicsWindow.Title = "Чтение параметров из файла"
GraphicsWindow.Width = 500
GraphicsWindow.Height = 500

Timer.Interval = 1000
Timer.Tick = Ontick

Sub Ontick

EndSub

Файл с параметрами для окна можно получить с помощью такой программы.

For i = 1 To 50
  File.WriteLine("setting.txt",i,Math.GetRandomNumber(500)+50)
endfor

Задание 11.Добавить кнопку удаления директории.
GraphicsWindow.Width = 500
GraphicsWindow.Height = 600
GraphicsWindow.FontSize = 11
GraphicsWindow.Title = ""
GraphicsWindow.BrushColor = "Blue"
Controls.ButtonClicked = OnButtonClick
Controls.TextTyped = OnTextTyped

Edit_1 = Controls.AddTextBox(50,50)
Controls.SetSize(Edit_1, 300,25)
Controls.SetTextBoxText(Edit_1,"new folder")

Button_1 = Controls.AddButton("создать директорию ", 50,150)
Controls.SetSize(Button_1, 300,50)

Sub OnTextTyped
edit = Controls.LastTypedTextBox
namefolder = Controls.GetTextBoxText(edit)
EndSub

Sub OnButtonClick
button = Controls.LastClickedButton
If button = Button_1 Then
path = Program.Directory
File.CreateDirectory(path+"\"+namefolder)
EndIf
Endsub

Задание 12.Доработать программу так,чтобы директория создавалась спустя пять секунд.

GraphicsWindow.Width = 500
GraphicsWindow.Height = 600
GraphicsWindow.FontSize = 11
GraphicsWindow.Title = ""
GraphicsWindow.BrushColor = "Blue"
Controls.ButtonClicked = OnButtonClick
Controls.TextTyped = OnTextTyped

Edit_1 = Controls.AddTextBox(50,50)
Controls.SetSize(Edit_1, 300,25)
Controls.SetTextBoxText(Edit_1,"new folder")

Button_1 = Controls.AddButton("создать директорию ", 50,150)
Controls.SetSize(Button_1, 300,50)

Sub OnTextTyped
edit = Controls.LastTypedTextBox
namefolder = Controls.GetTextBoxText(edit)
EndSub

Sub OnButtonClick
button = Controls.LastClickedButton
If button = Button_1 Then
Timer.Interval = 5000
EndIf
Endsub

 

Задание 13.Доработать программу так,чтобы таймер не выходил за отрицательные границы и чтобы увеличивался и отображался счетчик прошедших минут.

counter = 0
GraphicsWindow.Width = 500
GraphicsWindow.Height = 600
GraphicsWindow.FontSize = 11
GraphicsWindow.Title = "Обратный таймер"
GraphicsWindow.BrushColor = "Blue"
Controls.ButtonClicked = OnButtonClick
Controls.TextTyped = OnTextTyped

Edit_1 = Controls.AddTextBox(50,50)
Controls.SetSize(Edit_1, 300,25)
Controls.SetTextBoxText(Edit_1,"1000")

Button_1 = Controls.AddButton("запустить обратный таймер ", 50,150) 
Controls.SetSize(Button_1, 300,50)

Sub OnTextTyped
edit = Controls.LastTypedTextBox
myres = Controls.GetTextBoxText(edit)
EndSub

Sub OnButtonClick
  button = Controls.LastClickedButton
  If button = Button_1 Then 
    Controls.HideControl(edit)
    
    counter = myres
   Timer.Interval = 1000
   Timer.Tick = Ontick
  EndIf
Endsub

Sub Ontick
  counter = counter - 1
  GraphicsWindow.BrushColor = " White"
  GraphicsWindow.FillRectangle(0,0,500,200)
  GraphicsWindow.BrushColor = " Red"
  GraphicsWindow.FontSize = 25
  GraphicsWindow.DrawText(200,50,counter)
  
Endsub
 

Задание 14.Переделать программу так,чтобы вместо чисел выводилась посимвольно строка Hello World.

GraphicsWindow.Width = 500
GraphicsWindow.Height = 600
GraphicsWindow.FontSize = 25
GraphicsWindow.Title = ""
GraphicsWindow.BrushColor = "Blue"
Timer.Interval = 1000
Timer.Tick = Ontick
counter = 0
x = 0
y = 0
Sub Ontick
counter = counter + 1
GraphicsWindow.DrawText(x,y,counter)
x = x + 50
If x = 500 Then 
  x = 0 
  y = y + 25
  counter = 0
endif
endsub

Задание 15.Переделать программу так,чтобы прямоугольники чередовались с эллипсами.Подсказка:метод Remainder объекта Math отлично подходит для решения этой задачи.

GraphicsWindow.Width = 500
GraphicsWindow.Height = 600
GraphicsWindow.FontSize = 25
GraphicsWindow.Title = ""
GraphicsWindow.BrushColor = "Blue"
Timer.Interval = 1000
Timer.Tick = Ontick
counter = 0
x = 0
y = 0
Sub Ontick
counter = counter + 1
GraphicsWindow.FillRectangle(x,y,25,25)
x = x + 50
If x = 500 Then 
  x = 0 
  y = y + 50
  counter = 0
endif
endsub

 

Задание 16.Сделать так,чтобы при щелчке левой кнопкой мыши увеличивался размер квадрата.Подсказка:в данном случае надо использовать метод объекта Shapes - Zoom.

GraphicsWindow.Width = 500
GraphicsWindow.Height = 500
GraphicsWindow.FontSize = 25
GraphicsWindow.Title = ""
GraphicsWindow.BackgroundColor ="white" 
GraphicsWindow.MouseMove = OnMouseMove
my_rect = Shapes.AddRectangle(25, 25)
x = 0
y = 0
Sub OnMouseMove
x = GraphicsWindow.MouseX
y = GraphicsWindow.MouseY
Shapes.Move(my_rect,x, y)

EndSub

Задание 17.Переделать программу так,чтобы в графическом окне было четыре области отрисовки методом FillRectangle.Подсказка:необходимо использовать логические операции в операторах ветвления.

GraphicsWindow.Width = 500
GraphicsWindow.Height = 500
GraphicsWindow.FontSize = 25
GraphicsWindow.Title = ""
GraphicsWindow.BackgroundColor ="white" 
GraphicsWindow.MouseMove = OnMouseMove

Sub OnMouseMove
x = GraphicsWindow.MouseX
y = GraphicsWindow.MouseY
GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
If  y > 250 then
GraphicsWindow.FillRectangle(0,250,500,250)
EndIf

If y < 250 then
GraphicsWindow.FillRectangle(0,0,500,250)
EndIf

EndSub

Задание 18.Доработать программу так,чтобы эллипсы снизу тоже перемещались по оси x и по оси y.

GraphicsWindow.Width = 500
GraphicsWindow.Height = 500
GraphicsWindow.FontSize = 25
GraphicsWindow.Title = ""
GraphicsWindow.BackgroundColor ="white" 
For i = 0 to 10
Ellipse_1[i] = Shapes.AddEllipse(25, 25)
endfor

For i = 0 to 10
Ellipse_2[i] = Shapes.AddEllipse(25, 25)
endfor

Timer.Interval = 100
Timer.Tick = Ontick
For i = 0 to 10
arrayx[i] = 0
arrayy[i] = 0
endfor

For i = 0 to 10
arrayx2[i] = 450
arrayy2[i] = 0
endfor

Sub Ontick
  
For i = 0 to 5
Shapes.Move(Ellipse_1[i],arrayx[i] ,arrayy[i])
arrayx[i] = arrayx[i] + 10*i
endfor

For i = 6 to 10
Shapes.Move(Ellipse_1[i],arrayx[i] ,arrayy[i])
arrayy[i] =arrayy[i] + 10*i
endfor

Shapes.Move(Ellipse_2[0],450,450)

EndSub

Задание 19.Расположить прямоугольники в зеркальном порядке.
GraphicsWindow.Width = 500
GraphicsWindow.Height = 700
GraphicsWindow.FontSize = 25
GraphicsWindow.Title = ""
GraphicsWindow.BackgroundColor ="white" 

For index = 1 to 5 
my_rect = Shapes.AddRectangle(index*100, 25)
Shapes.Move(my_rect,250-index*50, index*25+25)
endfor

 

Задание 20.Доработать программу так,чтобы она получала ввод из текстового поля,результат отображала в графическом окне.

TextWindow.WriteLine("Введите число")
dig_text[0] = "ноль"
dig_text[1] = "один"
dig_text[2] = "два"
dig_text[3] = "три"
dig_text[4] = "четыре"
dig_text[5] = "пять"
dig_text[6] = "шесть"
dig_text[7] = "семь"
dig_text[8] = "восемь"
dig_text[9] = "девять"
num = TextWindow.ReadNumber()
length = Text.GetLength(num)

For i = 1 To length
  dig = Text.GetSubText(num,i,1)
  dig_array[i-1] = dig
EndFor

For i = 1 To length
For z = 0 To 9
if dig_array[i-1] = z Then
TextWindow.WriteLine(dig_text[z])
EndIf
EndFor
EndFor

Задание 21.Разработать цикл,который будет выводит сначала строку "123456",потом "12345" и так далее до строки "1".Данное задание не самое простое для программирования.)))
GraphicsWindow.Width = 500
GraphicsWindow.Height = 500
GraphicsWindow.FontSize = 25
GraphicsWindow.Title = ""
GraphicsWindow.BackgroundColor ="white" 
my_text = ""
For i = 0 To 5
my_text = Text.Append(my_text ,i+1)
GraphicsWindow.DrawText(0,i*50,my_text)

EndFor

Задание 22.Разработать цикл,который переворачивает строку.Данное задание очень легкое.)))
While 1 = 1
TextWindow.WriteLine("Введите строку текста")
my_text =TextWindow.Read()
TextWindow.WriteLine("Строка имеет размер "+Text.GetLength(my_text))
EndWhile

 

Просмотров: 30 | Добавил: moskov | Рейтинг: 0.0/0
Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]

Меню сайта

Мини-чат

Статистика


Онлайн всего: 1
Гостей: 1
Пользователей: 0

Форма входа

Календарь

«  Февраль 2024  »
ПнВтСрЧтПтСбВс
   1234
567891011
12131415161718
19202122232425
26272829

Архив записей

Друзья сайта

  • ЗОВ КОСМОСА

  • Хулиган Вселенной

  • Тюремная поэзия

  • Религиозная поэзия

  • Сайт клана ЛеГиоН
  • Поиск