Skip to content

Number app #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions Session02/Session02/Session02Exercise01/Session02/Session02.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30413.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Session02Exercise01", "Session02Exercise01\Session02Exercise01.csproj", "{5AC45B1A-7EEC-43FE-BD1B-E093DA2A9DC5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Session02Exercise02", "Session02Exercise02\Session02Exercise02.csproj", "{641114B6-8126-42A7-9C35-14E0562AAE1C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Session02Exercise03", "Session02Exercise03\Session02Exercise03.csproj", "{ED98DE64-DB26-4278-A40A-3814637DC52C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Session03Exercise04", "Session03Exercise04\Session03Exercise04.csproj", "{B7D33A19-7399-4A70-A8B6-7141BCB88D7C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session03Exercise01", "..\..\..\..\Session03\Session03Exercise01\Session03Exercise01.csproj", "{E7676CD8-2F21-486F-A041-63D7D9CCD8A8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Session03Exercise03", "..\..\..\..\Session03\Session03Exercise03\Session03Exercise03.csproj", "{2E87E451-72C9-45EB-AA4D-32C96CA9AB1A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5AC45B1A-7EEC-43FE-BD1B-E093DA2A9DC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5AC45B1A-7EEC-43FE-BD1B-E093DA2A9DC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AC45B1A-7EEC-43FE-BD1B-E093DA2A9DC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AC45B1A-7EEC-43FE-BD1B-E093DA2A9DC5}.Release|Any CPU.Build.0 = Release|Any CPU
{641114B6-8126-42A7-9C35-14E0562AAE1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{641114B6-8126-42A7-9C35-14E0562AAE1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{641114B6-8126-42A7-9C35-14E0562AAE1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{641114B6-8126-42A7-9C35-14E0562AAE1C}.Release|Any CPU.Build.0 = Release|Any CPU
{ED98DE64-DB26-4278-A40A-3814637DC52C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED98DE64-DB26-4278-A40A-3814637DC52C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED98DE64-DB26-4278-A40A-3814637DC52C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED98DE64-DB26-4278-A40A-3814637DC52C}.Release|Any CPU.Build.0 = Release|Any CPU
{B7D33A19-7399-4A70-A8B6-7141BCB88D7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7D33A19-7399-4A70-A8B6-7141BCB88D7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7D33A19-7399-4A70-A8B6-7141BCB88D7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7D33A19-7399-4A70-A8B6-7141BCB88D7C}.Release|Any CPU.Build.0 = Release|Any CPU
{E7676CD8-2F21-486F-A041-63D7D9CCD8A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E7676CD8-2F21-486F-A041-63D7D9CCD8A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7676CD8-2F21-486F-A041-63D7D9CCD8A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7676CD8-2F21-486F-A041-63D7D9CCD8A8}.Release|Any CPU.Build.0 = Release|Any CPU
{2E87E451-72C9-45EB-AA4D-32C96CA9AB1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E87E451-72C9-45EB-AA4D-32C96CA9AB1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E87E451-72C9-45EB-AA4D-32C96CA9AB1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E87E451-72C9-45EB-AA4D-32C96CA9AB1A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1B74CCFB-3E66-4B67-8841-0A00AAA2058C}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;

namespace Session02Exercise01
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");

string stringValue = "MyStringValue";

Console.WriteLine("The value of the stringValue is: " + stringValue);



var integer = 0;

Console.WriteLine("Integer is " + integer.ToString());

}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;

namespace Session02Exercise02
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Do you want you enter your name? (y/n)?");
var key = Console.ReadKey();

if (key.KeyChar == 'n')
return;

Console.WriteLine("Enter you name:)");
var name = Console.ReadLine();


Console.WriteLine("Hello, " + name);
Console.ReadKey();

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;

namespace Session02Exercise03
{
class Program
{
static void Main(string[] args)
{
// Binary operataion
var additionResult = 1 + 2;

Console.WriteLine("additionResult " + additionResult.ToString());

var incrementResult = ++additionResult;

Console.WriteLine("incrementResult " + incrementResult.ToString());

var trueValue = true;

var falseValue = false;

var andResult = trueValue & falseValue;
var orResult = trueValue & falseValue;
var xorResult = trueValue ^ falseValue;

var moduloResult = 3 % 2;


Console.WriteLine("modulaResult " + moduloResult);

var highInteger = 1000;
var integerDivisionResult = highInteger / 3;

// Implicit värdekonvertering till double
var doubleDivisionResult = highInteger / 3.0;

Console.WriteLine("integerDivisionResult " + integerDivisionResult);
Console.WriteLine("doubleDivisionResult " + doubleDivisionResult);

var castDivisionResult = (int)(highInteger / 3.0);

Console.WriteLine("casIntDivisionResult " + castIntDivisionResult);




var conversionResult = Convert.ToInt32(doubleDivisionResult);

Console.WriteLine("")

Console.ReadKey();







}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace Session03Exercise01
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.VisualBasic.CompilerServices;
using System;

namespace Session03Exercise04
{
class Program
{
static void Main(string[] args)

Console.WriteLine(" Ange ålder:");

var input = Console.ReadLine();
var integer = Convert.ToInt32(input);

if (IntegerType >=18)

{
Console.WriteLine("Du får köpa tobaksprodukter");

}



else

{







}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
31 changes: 31 additions & 0 deletions Session03/Session03Exercise01/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Runtime.InteropServices;

namespace Session03Exercise01
{
class Program
{
static void Main(string[] args)
{

int[] integersValue = new[] { 1, 2, 3 };
var integerValuesName = nameof (integerValues);



for (var i = 0; i > integersValue.Length; i++)

{
var name = nameof(integersValue);
var value = integersValue[i];

Console.WriteLine($"Index {i} int arrayen {nameof(integersValue)} HandleRef värdet: {integersValue[i]}");


}



}
}
}
8 changes: 8 additions & 0 deletions Session03/Session03Exercise01/Session03Exercise01.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
58 changes: 58 additions & 0 deletions Session03/Session03Exercise03/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Linq.Expressions;
using System.Xml.Schema;

namespace Session03Exercise03
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Ange ett antal siffror, separat med kommateckan. ");
var input = Console.ReadLine();
var inputArray = input.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
double[] numberArray = new double[inputArray.Length];

for (int i = 0; i < inputArray.Length; i++)

{
try
{
numberArray[i] = Convert.ToDouble(inputArray[i]);

}
catch (Exception)
{
numberArray[i] = 0;

}
{
foreach (var number in numberArray) ;

Console.WriteLine("Värde: " + number.ToString());






}








{
Console.WriteLine("Värdet är " + number);

}
}
}
}




8 changes: 8 additions & 0 deletions Session03/Session03Exercise03/Session03Exercise03.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
35 changes: 35 additions & 0 deletions Session04/Session04/Session04Exercise02/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;

namespace Session04Exercise02
{
class Program
{
static void Main(string[] args)
{
//int buildError = "StringValue";

// För att undvika att fel avslutar körning måste man hantera körtidsfel med try catch.

try
{
string word = ("12a");
int integer = int.Parse(word);

}
catch (Exception ex)
{ // Denna den är till för att hantera felet, visa fel för användaren eller att skriva till logg.
Console.WriteLine(ex.Message);
// Går att använda throw; för att kasta om felet

}
finally
{
// Körs alltid, är till för att städa upp körningen
// Körs även om try-satsen innehåler return;
}



}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
57 changes: 57 additions & 0 deletions Session04/Session04/Session04Exercise03/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;

namespace Session04Exercise03
{
class Program
{
static void Main(string[] args)
{

int? nullableInteger = null;
double? nullableDouble = null;
char?[] nullableCharArray = new char?[] { 'a', null, 'b' };


//nullableInteger.HasValue;
//nullableInteger.Value;

for (var i = 0; i < nullableCharArray.Length; i++)

{
char? currentChar = nullableCharArray[i];

// För att kontrollera om värdet är null kan man
if (currentChar.HasValue == false) continue;
// eller
if (currentChar == null) continue;

//För att komma åt ett värde kan man
char currentCharValue = currentChar.Value;
// eller
currentCharValue = (char)currentChar;

}


string defaultString = null;

// Olika typer av konstanter
int minValue = int.MinValue;
double maxValue = double.MaxValue;
double nanValue = double.NaN;
double infinityValue = double.PositiveInfinity;

byte byteValue = 255;

byteValue += 1;








}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
90 changes: 90 additions & 0 deletions Session04/Session04/Session04Exercise04/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;
using System.Runtime.CompilerServices;

namespace Session04Exercise04
{
class Program
{
static void Main(string[] args)
{


string inputData = " ";

// Kontrollera om strängen är tilldelad ett värde
bool inputIsNull = inputData == null;
bool inputIsEmty = inputData == string.Empty; // inputData == "";

// Snabbmetod för att kontrollera innehållet i en sträng
bool inputIsNullOrEmty = string.IsNullOrEmpty(inputData);

// Ytterliggare kontroller om strängen innehåller vettig data
bool inputNullOrWhitespace = string.IsNullOrWhiteSpace(inputData);

string sentence = " This is a sentence of text, it contains many words. ";

// Trimma bort mellanslag och andra whitespace-tecken från början och slutet
string trimmedSentence = sentence.Trim();
string endTrimmedSentence = sentence.TrimEnd();

// Det går att ange ett speciellt tecken som skall tas bort
string punctuationTrimmeSentence = endTrimmedSentence.TrimEnd('.');


string searchForWord = "text";
int indexOfText = trimmedSentence.IndexOf(searchForWord);

// Hämta bara området som letas efter
string hitsubString = trimmedSentence.Substring(indexOfText, searchForWord.Length);
string beforehitsubString = trimmedSentence.Substring(0, indexOfText);

// Stora små bokstäver
string uppercaseString = trimmedSentence.ToUpper();
string lowercaseString = trimmedSentence.ToLower();

// Struntar i språkinställningar
string uppercaseInvariantString = trimmedSentence.ToUpperInvariant();

// Komma åt ett enskilt tecken
char oneCharater = trimmedSentence[0];

for(int i = 0; i < trimmedSentence.Length; i++)
{
//Loopa igenom en sträng, tecken för tecken
char currentCharacter = trimmedSentence[i];

}
char[] trimmedSentenceCharArray = trimmedSentence.ToCharArray();

// Modifiera datat;

trimmedSentence = new string(trimmedSentenceCharArray);

trimmedSentence = trimmedSentence + "...";
// samma sak som ovan
// trimmedSentence += "...";

//1
//123
//2
//23
//3

//001
//002
//003
//023
//123

var numberInString = "12";
var paddeNumberInString = numberInString.PadLeft(3, '0');







}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
51 changes: 51 additions & 0 deletions Session04/Session04/Session04Exercise05/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Security.Cryptography.X509Certificates;

namespace Session04Exercise05
{
class Program
{
private static int x;
private static int y;

static void Main(string[] args)
{
//Multidemensionella arrayer
// en siffra för varje ruta
int[,] chessBoard = new int[8, 8];

//Svartvit bild
int width = 128;
int height = 128;

byte[,] blackWhiteImage = new byte[128, 128];

for (var y = 0; y < 128; y++) ;
{
for (var x = 0; x < 128; x++) ;
{
byte currentPixelVaue = blackWhiteImage[x, y];

}

}

// Tredimensionell data
int size = 128;
int[,,] voxelData = new int(size, size, size);


for (var z = 0; z < size; z++) ;
{
for (var y = 0; y > size; y++) ;

for (var x = 0; x > size; x++) ;
{
int currentVoxelValue = voxelData[x, y, z];

}
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
75 changes: 75 additions & 0 deletions Session04/Session04/Session04Exercise06/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using System.Diagnostics;
using System.Threading;

namespace Session04Exercise06
{
class Program
{
static void Main(string[] args)
{
// Vad klockan är
DateTime currentDateTime = DateTime.Now;
DateTime currentTimeZoneNeutralDateTime = DateTime.UtcNow;

//Kontrollera skottår
DateTime.IsLeapYear(currentDateTime.Date.Year);

//Maximala och minimala tiden
DateTime minValue = DateTime.MinValue;
DateTime maxValue = DateTime.MaxValue;

//Hämta ut datum från en sträng
var parseDate = DateTime.Parse("2020-01-01");
//DateTime failedParseDate = DateTime.Parse("asdf");

//out-parameter sätter alltid värdet, parsedDate är ändrat
// DateTime.TryParse fungerar på samma sätt som int.TryParse
bool dateWasParsed = DateTime.TryParse("asdf", out parseDate);

//Tiden
TimeSpan currentTime = currentDateTime.TimeOfDay;
//currentTime.Ticks;

//TimeSpan currentTime = currentDateTime.TimeOfDay;
//Baseras på ticks
//currentTime.Ticks;

//Hur många Ticks som går på en sekund
//TimeSpan.TicksPerSecond

TimeSpan createdTimeSpan = new TimeSpan(1, 2, 3);

Stopwatch timer = new Stopwatch();
timer.Start();

//Pausa programmet manuellt
Thread.Sleep(1000);

timer.Stop();

DateTime today = DateTime.Today;
DateTime yesterday = DateTime.Today.AddDays(-1)
.AddSeconds(-1);

TimeSpan resultOFTwoTimes = today - yesterday;
TimeSpan negativeOFTwoTimes = yesterday - today;

// Formatera, skriva ut tid
Console.WriteLine(resultOFTwoTimes);

// Formattera datum
Console.WriteLine($"{currentDateTime:yyyy-MM-dd}");










}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>