
Московский государственный технический университет им. Н.Э. Баумана
Кафедра ИУ-7
Программное обеспечение ЭВМ
и информационные технологии.
Отчёт
по проекту «Органайзер»
Студент группы Э3-22: Пятин Иван
Преподаватель: Неземский Валентин Иванович
Москва 2013 г.
Цель проекта.
Закрепление полученных компетенций (знаний, умений и навыков) в первом семестре и приобретении новых знаний по визуальному объектно-ориентированному программированию
Содержания проекта:
Проект содержит следующие приложения:
Календарь………………………………………………………………………….… 3стр.
Аналоговые и электронные часы с будильником…………………………….... 9стр.
Научный калькулятор………………………………………………………………13стр.
Обработка массивов…………………………………………………………………21стр.
Записная книжка…………………………………………………………………….25стр.
Типовой расчет №1 по Мат. Анализу……………………………………………..28стр.
Забавная игра…………………………………………………………………………34стр.
Динамическая картинка…………………………………………………………….38стр.
Обработка строк………………………………………………………………………44стр.
Построение графиков………………………………………………………………..46стр.
Литература, используемая в ходе работы над проектом:
1. М.Фленов Библия Delphi 2011
2. C Бобровский Delphi 7 2006
3. А.Я. Архангельский Программирование в Delphi 6
Календарь
Интерфейс:
Код программы
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, ExtCtrls, DateUtils, StdCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
StringGrid1: TStringGrid;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;1
Label1: TLabel;
Button3: TButton;
Button4: TButton;
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
var
year,month,day:word;
date:TdateTime;
b:boolean;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
firstday:TDateTime;
fd,i,j:integer;
st:string;
begin
b:=false;
if month=12 then
begin
month:=1;
year:=year+1;
end
else
month:=month+1;
date:=encodedate(year,month,day);
panel1.caption:=LongMonthNames[MonthOfTheYear(date)]+' '+inttostr(year);
firstday:=incday(date,(-1)*day+1);
fd:=DayOfTheWeek(firstday);
for i:=0 to stringgrid1.ColCount-1 do
for j:=1 to stringgrid1.rowcount-1 do
begin
if ((7*(j-1)+i-fd+2)>0) and (j<(stringgrid1.rowcount-2)) then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (j=(stringgrid1.rowcount-2)) or (j=(stringgrid1.rowcount-1)) then
begin
if (month=1) or (month=3) or (month=5) or (month=7) or (month=8) or (month=10) or (month=12) then
begin
if (7*(j-1)+i-fd+2)<=31 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>31 then
stringgrid1.cells[i,j]:='';
end;
if (month=4) or (month=6) or (month=9) or (month=11) then
begin
if (7*(j-1)+i-fd+2)<=30 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>30 then
stringgrid1.cells[i,j]:='';
end;
if (month=2) then
begin
if ((year mod 4=0) and (year mod 100<>0)) or (year mod 400=0) then
begin
if (7*(j-1)+i-fd+2)<=29 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>29 then
stringgrid1.cells[i,j]:='';
end
else
begin
if (7*(j-1)+i-fd+2)<=28 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>28 then
stringgrid1.cells[i,j]:='';
end;
end;
end;
end; // for
for i:=0 to fd-2 do
stringgrid1.Cells[i,1]:='';
end;
procedure TForm1.Button2Click(Sender: TObject);
var
firstday:TDateTime;
fd,i,j:integer;
st:string;
begin
b:=false;
if month=1 then
begin
month:=12;
year:=year-1;
end
else
month:=month-1;
date:=encodedate(year,month,day);
panel1.caption:=LongMonthNames[MonthOfTheYear(date)]+' '+inttostr(year);
firstday:=incday(date,(-1)*day+1);
fd:=DayOfTheWeek(firstday);
for i:=0 to stringgrid1.ColCount-1 do
for j:=1 to stringgrid1.rowcount-1 do
begin
if ((7*(j-1)+i-fd+2)>0) and (j<(stringgrid1.rowcount-2)) then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (j=(stringgrid1.rowcount-2)) or (j=(stringgrid1.rowcount-1)) then
begin
if (month=1) or (month=3) or (month=5) or (month=7) or (month=8) or (month=10) or (month=12) then
begin
if (7*(j-1)+i-fd+2)<=31 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>31 then
stringgrid1.cells[i,j]:='';
end;
if (month=4) or (month=6) or (month=9) or (month=11) then
begin
if (7*(j-1)+i-fd+2)<=30 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>30 then
stringgrid1.cells[i,j]:='';
end;
if (month=2) then
begin
if ((year mod 4=0) and (year mod 100<>0)) or (year mod 400=0) then
begin
if (7*(j-1)+i-fd+2)<=29 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>29 then
stringgrid1.cells[i,j]:='';
end
else
begin
if (7*(j-1)+i-fd+2)<=28 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>28 then
stringgrid1.cells[i,j]:='';
end;
end;
end;
end; // for
for i:=0 to fd-2 do
stringgrid1.Cells[i,1]:='';
end;
procedure TForm1.Button3Click(Sender: TObject);
var
date1:TDateTime;
firstday:TDateTime;
fd,i,j:integer;
st:string;
begin
b:=true;
try
date1:=strtodate(edit1.Text);
decodedate(date1,year,month,day);
date:=encodedate(year,month,day);
panel1.caption:=LongMonthNames[MonthOfTheYear(date)]+' '+inttostr(year);
firstday:=incday(date,(-1)*day+1);
fd:=DayOfTheWeek(firstday);
for i:=0 to stringgrid1.ColCount-1 do
for j:=1 to stringgrid1.rowcount-1 do
begin
if ((7*(j-1)+i-fd+2)>0) and (j<(stringgrid1.rowcount-2)) then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (j=(stringgrid1.rowcount-2)) or (j=(stringgrid1.rowcount-1)) then
begin
if (month=1) or (month=3) or (month=5) or (month=7) or (month=8) or (month=10) or (month=12) then
begin
if (7*(j-1)+i-fd+2)<=31 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>31 then
stringgrid1.cells[i,j]:='';
end;
if (month=4) or (month=6) or (month=9) or (month=11) then
begin
if (7*(j-1)+i-fd+2)<=30 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>30 then
stringgrid1.cells[i,j]:='';
end;
if (month=2) then
begin
if ((year mod 4=0) and (year mod 100<>0)) or (year mod 400=0) then
begin
if (7*(j-1)+i-fd+2)<=29 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>29 then
stringgrid1.cells[i,j]:='';
end
else
begin
if (7*(j-1)+i-fd+2)<=28 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>28 then
stringgrid1.cells[i,j]:='';
end;
end;
end;
end; // for
for i:=0 to fd-2 do
stringgrid1.Cells[i,1]:='';
Except
showmessage('Неверный ввод');
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
date1:TDateTime;
firstday:TDateTime;
fd,i,j:integer;
begin
decodedate(now,year,month,day);
date:=encodedate(year,month,day);
panel1.caption:=LongMonthNames[MonthOfTheYear(date)]+' '+inttostr(year);
firstday:=incday(date,(-1)*day+1);
fd:=DayOfTheWeek(firstday);
for i:=0 to stringgrid1.ColCount-1 do
for j:=1 to stringgrid1.rowcount-1 do
begin
if ((7*(j-1)+i-fd+2)>0) and (j<(stringgrid1.rowcount-2)) then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (j=(stringgrid1.rowcount-2)) or (j=(stringgrid1.rowcount-1)) then
begin
if (month=1) or (month=3) or (month=5) or (month=7) or (month=8) or (month=10) or (month=12) then
begin
if (7*(j-1)+i-fd+2)<=31 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>31 then
stringgrid1.cells[i,j]:='';
end;
if (month=4) or (month=6) or (month=9) or (month=11) then
begin
if (7*(j-1)+i-fd+2)<=30 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>30 then
stringgrid1.cells[i,j]:='';
end;
if (month=2) then
begin
if ((year mod 4=0) and (year mod 100<>0)) or (year mod 400=0) then
begin
if (7*(j-1)+i-fd+2)<=29 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>29 then
stringgrid1.cells[i,j]:='';
end
else
begin
if (7*(j-1)+i-fd+2)<=28 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>28 then
stringgrid1.cells[i,j]:='';
end;
end;
end;
end; // for
for i:=0 to fd-2 do
stringgrid1.Cells[i,1]:='';
end;
procedure TForm1.FormCreate(Sender: TObject);
var
firstday:TDateTime;
fd,i,j:integer;
st:string;
begin
with stringgrid1 do
begin
cells[0,0]:='Пн';
cells[1,0]:='Вт';
cells[2,0]:='Ср';
cells[3,0]:='Чт';
cells[4,0]:='Пт';
cells[5,0]:='Сб';
cells[6,0]:='Вс';
end;
decodedate(now,year,month,day);
date:=encodedate(year,month,day);
panel1.caption:=LongMonthNames[MonthOfTheYear(date)]+' '+inttostr(year);
firstday:=incday(date,(-1)*day+1);
fd:=DayOfTheWeek(firstday);
for i:=0 to stringgrid1.ColCount-1 do
for j:=1 to stringgrid1.rowcount-1 do
begin
if ((7*(j-1)+i-fd+2)>0) and (j<(stringgrid1.rowcount-2)) then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (j=(stringgrid1.rowcount-2)) or (j=(stringgrid1.rowcount-1)) then
begin
if (month=1) or (month=3) or (month=5) or (month=7) or (month=8) or (month=10) or (month=12) then
begin
if (7*(j-1)+i-fd+2)<=31 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>31 then
stringgrid1.cells[i,j]:='';
end;
if (month=4) or (month=6) or (month=9) or (month=11) then
begin
if (7*(j-1)+i-fd+2)<=30 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>30 then
stringgrid1.cells[i,j]:='';
end;
if (month=2) then
begin
if ((year mod 4=0) and (year mod 100<>0)) or (year mod 400=0) then
begin
if (7*(j-1)+i-fd+2)<=29 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>29 then
stringgrid1.cells[i,j]:='';
end
else
begin
if (7*(j-1)+i-fd+2)<=28 then
stringgrid1.cells[i,j]:=inttostr(7*(j-1)+i-fd+2);
if (7*(j-1)+i-fd+2)>28 then
stringgrid1.cells[i,j]:='';
end;
end;
end; // for
for i:=0 to fd-2 do
stringgrid1.Cells[i,1]:='';
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
year1,month1,day1:word;
begin
with stringgrid1.Canvas do
begin
brush.color:=clred;
if ACol=6 then
begin
FillRect(Rect);
TextOut(Rect.Left+2, Rect.Top+2, Stringgrid1.Cells[ACol, ARow]);
end;
brush.color:=claqua;
pen.Color:=clblack;
pen.Width:=4;
decodedate(now,year1,month1,day1);
if ((year1=year) and (month1=month)) or (b=true) then
if stringgrid1.Cells[ACol,ARow]=inttostr(day) then
begin
rectangle(rect.Left-2,rect.Top,rect.Right,rect.Bottom);
TextOut(Rect.Left+2, Rect.Top+2, Stringgrid1.Cells[ACol, ARow]);
End; end.