static void Main(string[] args) { Program number = new Program(); int a = 0; int b = 0; Console.WriteLine("Welcome to 'Fun With Numbers!'"); Console.WriteLine("Today we are going to practice multiplication."); Console.WriteLine("You will be asked a multiplication question."); Console.WriteLine("Something like, 'What is 5 times 5?"); Console.WriteLine("If you think you know the answer, type it in."); Console.WriteLine("Enter 0 to exit."); // Create an object so that the program can call the equation method NumberMethods run = new NumberMethods(); run.Equation(a, b); }
private static void Main() { Console.WriteLine("Triangle Area:"); Console.WriteLine(TriangleMethods.CalcTriangleArea(3, 4, 5)); Console.WriteLine("\nDigit As Word:"); Console.WriteLine(DigitMethods.DigitAsWord(5)); Console.WriteLine("\nFind Max:"); Console.WriteLine(NumberMethods.FindMax(5, -1, 3, 2, 14, 2, 3)); Console.WriteLine("\nNumbers in different formats:"); ConsolePrint.NumberInFormat(1.3, "f"); ConsolePrint.NumberInFormat(0.75, "%"); ConsolePrint.NumberInFormat(2.30, "r"); Console.WriteLine("\nPoints and distance:"); var pointFirst = new Point2D(3, -1); var pointLast = new Point2D(3, 2.5); Console.WriteLine(pointFirst.DistanceTo(pointLast)); Console.WriteLine("Points are horizontal to each other -> {0}", pointFirst.IsHorizontalTo(pointLast)); Console.WriteLine("Points are vertical to each other -> {0}", pointFirst.IsVerticalTo(pointLast)); Console.WriteLine("\nStudents:"); Student peter = new Student("Peter", "Ivanov", DateTime.Parse("17.03.1992")); peter.OtherInfo = "From Sofia"; Student stella = new Student("Stella", "Markova", DateTime.Parse("03.11.1993")); stella.OtherInfo = "From Vidin, gamer, high results"; Console.WriteLine("Peter's Bday: {0}", peter.BirthDay.ToShortDateString()); Console.WriteLine("Stella's Bday: {0}", stella.BirthDay.ToShortDateString()); Console.WriteLine( "{0} older than {1} -> {2}", peter.FirstName, stella.FirstName, peter.IsOlderThan(stella)); }
static public void NewDocument(Album currentAlbum, string path) { Document pdf = new Document(PageSize.A4, 0, 0, 0, 0); Document document = new Document(); PdfWriter pdfWriter = PdfWriter.GetInstance(document, new FileStream(path + "\\" + currentAlbum.Name + ".pdf", FileMode.Create)); iTextSharp.text.Rectangle one = new iTextSharp.text.Rectangle(0, 0, NumberMethods.PixelsToPdfCoords(1084), NumberMethods.PixelsToPdfCoords(600)); one.BackgroundColor = new BaseColor(Color.FromArgb(36, 39, 47)); document.SetPageSize(one); document.Open(); iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(ImageMethods.ConvertByteArrayToImage(currentAlbum.CoverPhoto), ImageMethods.ConvertByteArrayToImage(currentAlbum.CoverPhoto).RawFormat); img.ScaleAbsolute((int)NumberMethods.PixelsToPdfCoords(450), (int)NumberMethods.PixelsToPdfCoords(450)); img.SetAbsolutePosition(0, NumberMethods.PixelsToPdfCoords(75)); document.Add(img); //img added and background setted PdfContentByte FirstDivider = pdfWriter.DirectContent; FirstDivider.SetLineWidth(2.0f); // Make a bit thicker than 1.0 default FirstDivider.SetGrayStroke(1); // 1 = black, 0 = white FirstDivider.MoveTo(0, (int)NumberMethods.PixelsToPdfCoords(60)); FirstDivider.LineTo(document.PageSize.Width, (int)NumberMethods.PixelsToPdfCoords(60)); FirstDivider.Stroke(); //setted first divider PdfContentByte SecondDivider = pdfWriter.DirectContent; SecondDivider.SetLineWidth(2.0f); // Make a bit thicker than 1.0 default SecondDivider.SetGrayStroke(1); // 1 = black, 0 = white SecondDivider.MoveTo(0, (int)NumberMethods.PixelsToPdfCoords(540)); SecondDivider.LineTo(document.PageSize.Width, (int)NumberMethods.PixelsToPdfCoords(540)); SecondDivider.Stroke(); //setted second divider float XMultiplier = 11.17647058823529F; string ttf = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "CENTURY.TTF"); BaseFont baseFont = BaseFont.CreateFont(ttf, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); PdfContentByte cb = pdfWriter.DirectContent; cb.SetColorFill(BaseColor.WHITE); cb.SetFontAndSize(baseFont, 24); cb.BeginText(); string text = "Информация о альбоме"; // put the alignment and coordinates here cb.ShowTextAligned(0, text, (int)NumberMethods.PixelsToPdfCoords(17), (int)NumberMethods.PixelsToPdfCoords(600 - 50), 0); cb.EndText(); // int CurrentHeight = 500; int CurrentWidth = 480; int SpaceBetween = 10; int SpaceHeight = 60; // Name string name = currentAlbum.Name; cb.SetFontAndSize(baseFont, 24); cb.ShowTextAligned(0, name, (int)NumberMethods.PixelsToPdfCoords(480), (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); cb.BeginText(); cb.EndText(); // Author cb.SetFontAndSize(baseFont, 18); cb.SetColorFill(BaseColor.LIGHT_GRAY); CurrentHeight -= SpaceHeight; string SubName = "Автор:"; cb.ShowTextAligned(0, SubName, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth), (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); cb.SetColorFill(BaseColor.WHITE); string Name = currentAlbum.Author.Name; float widthString = baseFont.GetWidthPoint(SubName, 18); cb.ShowTextAligned(0, Name, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth + SpaceBetween) + widthString, (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); //Year cb.SetFontAndSize(baseFont, 16); cb.SetColorFill(BaseColor.LIGHT_GRAY); CurrentHeight -= SpaceHeight; SubName = "Год выпуска:"; cb.ShowTextAligned(0, SubName, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth), (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); cb.SetColorFill(BaseColor.WHITE); Name = currentAlbum.ReleaseYear.ToString(); widthString = baseFont.GetWidthPoint(SubName, 16); cb.ShowTextAligned(0, Name, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth + SpaceBetween) + widthString, (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); //Genre cb.SetFontAndSize(baseFont, 18); cb.SetColorFill(BaseColor.LIGHT_GRAY); CurrentHeight -= SpaceHeight; SubName = "Жанр:"; cb.ShowTextAligned(0, SubName, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth), (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); cb.SetColorFill(BaseColor.WHITE); Name = currentAlbum.Genre.Name; widthString = baseFont.GetWidthPoint(SubName, 18); cb.ShowTextAligned(0, Name, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth + SpaceBetween) + widthString, (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); //Carrier cb.SetColorFill(BaseColor.LIGHT_GRAY); CurrentHeight -= SpaceHeight; SubName = "Тип носителя:"; cb.ShowTextAligned(0, SubName, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth), (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); cb.SetColorFill(BaseColor.WHITE); Name = currentAlbum.Carrier.Name; widthString = baseFont.GetWidthPoint(SubName, 18); cb.ShowTextAligned(0, Name, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth + SpaceBetween) + widthString, (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); //Type cb.SetColorFill(BaseColor.LIGHT_GRAY); CurrentHeight -= SpaceHeight; SubName = "Тип альбома:"; cb.ShowTextAligned(0, SubName, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth), (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); cb.SetColorFill(BaseColor.WHITE); Name = currentAlbum.Type.Name; widthString = baseFont.GetWidthPoint(SubName, 18); cb.ShowTextAligned(0, Name, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth + SpaceBetween) + widthString, (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); //TackCount cb.SetColorFill(BaseColor.LIGHT_GRAY); CurrentHeight -= SpaceHeight; SubName = "Количество дорожек:"; cb.ShowTextAligned(0, SubName, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth), (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); cb.SetColorFill(BaseColor.WHITE); Name = currentAlbum.TrackCount.ToString(); widthString = baseFont.GetWidthPoint(SubName, 18); cb.ShowTextAligned(0, Name, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth + SpaceBetween) + widthString, (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); //Releasing label cb.SetColorFill(BaseColor.LIGHT_GRAY); CurrentHeight -= SpaceHeight; SubName = "Выпускающий лэйбл:"; cb.ShowTextAligned(0, SubName, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth), (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); cb.SetColorFill(BaseColor.WHITE); Name = currentAlbum.ReleasingLabel.Name; widthString = baseFont.GetWidthPoint(SubName, 18); cb.ShowTextAligned(0, Name, (int)NumberMethods.PixelsToPdfCoords(CurrentWidth + SpaceBetween) + widthString, (int)NumberMethods.PixelsToPdfCoords(CurrentHeight), 0); document.Close(); }
public void FindNextBiggerNumberNUnitTest_NumberNotPositive_ThrowsException(int number) { Assert.Throws <ArgumentOutOfRangeException>(() => NumberMethods.FindNextBiggerNumber(number)); }
public int FindNextBiggerNumberNUnitTest1(int number) { return(NumberMethods.FindNextBiggerNumber(number)); }
public int InsertNumberNUnitTest1(int first, int second, int i, int j) { return(NumberMethods.InsertNumber(first, second, i, j)); }
public void InsertNumberNUnitTest_BitILessThanBitJ_ThrowsException(int first, int second, int i, int j) { Assert.Throws <ArgumentOutOfRangeException>(() => NumberMethods.InsertNumber(first, second, i, j)); }
public void InsertNumberTest_NumbersMoreThan15_ThrowsException() { Assert.ThrowsException <ArgumentOutOfRangeException>(() => NumberMethods.InsertNumber(9, 16, 0, 3)); }
public void InsertNumberTest_NumbersLessThan8_ThrowsException() { Assert.ThrowsException <ArgumentOutOfRangeException>(() => NumberMethods.InsertNumber(7, 10, 2, 3)); }
public void InsertNumberTest_BitILessThanBitJ_ThrowsException() { Assert.ThrowsException <ArgumentOutOfRangeException>(() => NumberMethods.InsertNumber(9, 10, 5, 3)); }
public void InsertNumberTest3() { Assert.AreEqual(NumberMethods.InsertNumber(8, 15, 3, 8), 120); }
public void InsertNumberTest2() { Assert.AreEqual(NumberMethods.InsertNumber(8, 15, 0, 0), 9); }
public void InsertNumberTest1() { Assert.AreEqual(NumberMethods.InsertNumber(15, 15, 0, 0), 15); }