Skip to content

Commit

Permalink
Merge pull request #225 from Egorkin-enabled/main
Browse files Browse the repository at this point in the history
Лабораторная работа №5: Работа со структурами (Вариант №11)
  • Loading branch information
jskonst authored Dec 16, 2023
2 parents 6c73bac + 54a7df5 commit 150f016
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@


# История изменений
## Лабораторная работа №4 (Варинат 11) [Fri Dec 8 9:38:00 2023]
Была описана структура `Document` на языке программирования `Golang`. Структурва документ имеет 3 закрытых поля:
+ documentPath [тип string]
+ documntType [тип string]
+ documentSize [тип int64]

Были написаны:
+ Конструктор
+ 3 геттера:
+ Для documentPath
+ Для documntType
+ Для documentSize
+ 1 сеттер для documentSize с проверкой на допустимые значения (размер не может быть меньше 0)

## Лабораторные работы 1, 2 & 3 (Вариант 11) [Fri Sep 22 22:27:17 2023]
Для выполнения работ был исользован язык программирования `Golang`. В соответствии с варинатом 11 была решена задача из списка ниже:

Expand Down
47 changes: 47 additions & 0 deletions golang/lab_4/Document.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package lab_4

// Kozlov Egor 1/278: Variant 11

import "fmt"

type document struct {
documentPath string
documentType string
documentSize int64
}

func NewDocument(path, documentType string, documentSize int64) (*document, error) {
document := document{
documentPath: path,
documentType: documentType,
}

error := document.SetDocumentSize(documentSize)

if error != nil {
return nil, error
}

return &document, error
}

func (d *document) DocumentPath() string {
return d.documentPath
}

func (d *document) DocumentType() string {
return d.documentType
}

func (d *document) DocumentSize() int64 {
return d.documentSize
}

func (d *document) SetDocumentSize(size int64) error {
if size < 0 {
return fmt.Errorf("Error: size must be >= 0. Current value: %v", size)
}

d.documentSize = size
return nil
}

0 comments on commit 150f016

Please sign in to comment.