Report Lab 1.1
Report Lab 1.1
Basics of Programming
Laboratory work 1.1
STUDY OF DESCRIPTION AND APPLICATION OF CLASSES
Variant - 5
Prepared by:
student of SE-121 en.,
Demchuk Oksana
Accepted by:
Vasilieva M.D.
Kiev, 2022
Task
1. Learn the description of class in languages С++ and С#.
2. Study the mechanisms of creating, using and destroying objects of classes
in programming languages С++ and С#.
3. Write a program in languages C++ and С# to demonstrate examples of the
class application (choose the variant to be performed in Appendix 1)
Procedure
C++
Source.cpp
#include "String.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
Strings *newText = new Strings("hgfedFGRAcba");
newText->sort();
newText->print();
delete newText;
return 0;
}
String.h
#pragma once
#include <iostream>
#include<string>
#include <regex>
using namespace std;
class Strings {
Strings(string newText)
{
for (int i = 0; i < StringLength(); i++) {
if (newText[i] > 96 && newText[i] < 123){
text += newText[i];
}
}
}
~Strings(){}
int StringLength() {
int len = 0;
while (text[len] != '\0') {
len++;
}
return len;
}
void sort()
{
char temp;
for (int i = 0; i < StringLength(); i++) {
};
C#
Program.cs
using Laboratory1;
namespace MainProgram
{
class Program
{
static void Main(string[] args)
{
task();
}
}
StringClass.cs
using System.Text;
using System.Text.RegularExpressions;
namespace Laboratory1
{
class StringClass
{
private string text="";
public StringClass(string newText)
{
value=newText;
}
public int StringLength()
{
int len = 0;
foreach (char c in text)
{
len++;
}
return len;
}
public string getText()
{
return text;
}
public void sortString()
{
char temp;
StringBuilder temp2 = new StringBuilder(text);
for (int i = 0; i < StringLength(); i++)
{
~StringClass()
{
}
}
}
Conclusion
During the laboratory work I studied the description of classes, learned to create, use and destroy
the objects of classes.