-
Notifications
You must be signed in to change notification settings - Fork 23
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
Evgenij Satyev #59
Open
yinegve
wants to merge
28
commits into
ISUCT:Evgenij_Satyev
Choose a base branch
from
yinegve:Evgenij_Satyev
base: Evgenij_Satyev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Evgenij Satyev #59
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
aeb27bc
Sample of 1st lab
0247220
Tests samples
d514055
Added actions file
jskonst b29aa60
Fixed run steps (#28)
jskonst dbae387
Test actions on PR (#30)
jskonst 953427e
Added tests and sample A|B tasks
jskonst 62b5d9e
Added class task example, added vscode conf
aa0b4b1
Merge branch 'master' of https://github.com/ISUCT/Tprogramming_147_2019
481bc20
Merge branch 'master' into Evgenij_Satyev
yinegve dc366c9
Function v1.0
yinegve 09e9cc0
Function v1.1
yinegve 370715c
Update
yinegve 7b7eece
FunctionTest v1.0
yinegve dd98a0c
AddTests
yinegve c88f283
AddClass
yinegve 9531f0d
AddTestClass
yinegve c71172b
Add function collection
yinegve 5c98827
Add Test + collection
yinegve 455f611
add class+exception
yinegve 15b0626
add test+exception
yinegve c37eb76
Add SuperClass
yinegve d4c523b
Merge branch 'Evgenij_Satyev' into Evgenij_Satyev
yinegve 0f7e0c6
Add SuperClass plus
yinegve 4fb9109
Correct superclass
yinegve a427df4
Calculation Age + AgeTest
yinegve 42513c5
AgeTest plus
yinegve a4a8024
Calculation Age correct
yinegve afbfe1d
SuperClass correct
yinegve File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace CourseApp.Tests | ||
{ | ||
public class AgeTest | ||
{ | ||
[Fact] | ||
public void TestDate() | ||
{ | ||
var res = new AgeCalc(); | ||
Assert.Equal("Вам 19 лет, 2 месяцев, 18 дней", res.CalcAge(22, 10, 2000, 8, 1, 2020)); | ||
} | ||
|
||
[Fact] | ||
public void BirthdayAboveToday() | ||
{ | ||
var res = new AgeCalc(); | ||
try | ||
{ | ||
res.CalcAge(27, 11, 2025, 8, 1, 2020); | ||
Assert.True(false); | ||
} | ||
catch | ||
{ | ||
Console.WriteLine("Birthday > Today"); | ||
Assert.True(true); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void CurrentDayIsBirthdayTest() | ||
{ | ||
var res = new AgeCalc(); | ||
var day = DateTime.Today.Day; | ||
var month = DateTime.Today.Month; | ||
var year = DateTime.Today.Year; | ||
try | ||
{ | ||
Assert.Equal(res.CalcAge(12, 12, 2019, 12, 12, 2019), $"Возраст:0 лет, 0 месяцев, 0 дней"); | ||
} | ||
catch | ||
{ | ||
Assert.True(true); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace CourseApp.Tests | ||
{ | ||
public class WeaponTest | ||
{ | ||
[Fact] | ||
public void TestEmptyConstructorForPistol() | ||
{ | ||
var item = new Pistol(); | ||
Assert.Equal(0, item.Kalibr); | ||
Assert.Equal("No model", item.Model); | ||
} | ||
|
||
[Fact] | ||
public void TestForToString() | ||
{ | ||
var item = new Rifle(); | ||
Assert.Equal("Rifle-No model, 0, True", item.ToString()); | ||
} | ||
|
||
[Fact] | ||
public void TestShoot() | ||
{ | ||
var item = new Rifle("Glock", 10, true); | ||
var act = item.Shoot(true); | ||
Assert.Equal($"Rifle Glock and 10 hit!", act); | ||
} | ||
|
||
[Fact] | ||
public void TestCorrectIncorrectSetKalibr() | ||
{ | ||
var item = new Pistol(); | ||
try | ||
{ | ||
item.Kalibr = -5; | ||
Assert.Equal(-5, item.Kalibr); | ||
} | ||
catch (System.Exception) | ||
{ | ||
Assert.True(true); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void TestNumShoot() | ||
{ | ||
var item = new Pistol("Glock", 10, true); | ||
var act = item.NumShoot(15); | ||
Assert.Equal($"Glock made of 15 shots", act); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
|
||
namespace CourseApp | ||
{ | ||
public class AgeCalc | ||
{ | ||
private DateTime now = DateTime.Today; | ||
|
||
public string CalcAge(int day, int month, int year) | ||
{ | ||
var today = DateTime.Today; | ||
var ageCalc = new AgeCalc(); | ||
return ageCalc.CalcAge(day, month, year, today.Day, today.Month, today.Year); | ||
} | ||
|
||
public string CalcAge(int day, int month, int year, int heDay, int heMonth, int heYear) | ||
{ | ||
var birthday = new DateTime(year, month, day); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Два метода дублируют код. Один должен вызывать другой |
||
var today = new DateTime(heYear, heMonth, heDay); | ||
|
||
if (now.Ticks < birthday.Ticks) | ||
{ | ||
throw new Exception("You haven't been born yet"); | ||
} | ||
else | ||
{ | ||
var res = new DateTime(today.Ticks - birthday.Ticks); | ||
return $"Вам {res.Year - 1} лет, {res.Month - 1} месяцев, {res.Day - 1} дней"; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
|
||
namespace CourseApp | ||
{ | ||
public class Rifle : Weapon | ||
{ | ||
private double kalibr; | ||
|
||
public Rifle() | ||
: this("No model", 0, true) | ||
{ | ||
} | ||
|
||
public Rifle(string model, double kalibr, bool hit) | ||
: base(model, kalibr, hit) | ||
{ | ||
Model = model; | ||
Kalibr = kalibr; | ||
Hit = hit; | ||
} | ||
|
||
public override double Kalibr | ||
{ | ||
get | ||
{ | ||
return this.kalibr; | ||
} | ||
|
||
set | ||
{ | ||
if (value >= 0 && value < 20) | ||
{ | ||
this.kalibr = value; | ||
} | ||
else | ||
{ | ||
throw new Exception("Enter correct kalibr"); | ||
} | ||
} | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return $"Rifle-{Model}, {Kalibr}, {Hit}"; | ||
} | ||
|
||
public override string Shoot(bool hit) | ||
{ | ||
if (hit == true) | ||
{ | ||
return $"Rifle {Model} and {Kalibr} hit!"; | ||
} | ||
else | ||
{ | ||
return $"Rifle {Model} and {Kalibr} not hit!"; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
|
||
namespace CourseApp | ||
{ | ||
public abstract class Weapon | ||
{ | ||
public Weapon(string model, double kalibr, bool hit) | ||
{ | ||
Model = model; | ||
Kalibr = kalibr; | ||
Hit = hit; | ||
} | ||
|
||
public virtual string Model { get; set; } | ||
|
||
public virtual double Kalibr { get; set; } | ||
|
||
public virtual bool Hit { get; set; } | ||
|
||
public abstract string Shoot(bool canShoot); | ||
|
||
public new virtual string ToString() | ||
{ | ||
return $"Weapon-{Model}, {Kalibr}, {Hit}"; | ||
} | ||
|
||
public virtual string NumShoot(int shot) | ||
{ | ||
return $"{Model} made of {shot} shots"; | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тестов как то сильно маловато