static void Main(string[] args) { var customer = new Customer(); //var rating = customer.CalculateRating(); // Wont work if method is private Amazon.RateCalculator calculator = new RateCalculator(); // Wont work if method is internal (Amazon is referenced) }
static void Main(string[] args) { Console.WriteLine("Example Access Modifiers"); var customer = new Customer(); customer.Promote(); Amazon.RateCalculator calculator = new RateCalculator(); Console.WriteLine("=========================="); Console.WriteLine("Example Constructor and Inheritance"); var car = new Car("D19920ZTT"); Console.WriteLine("=========================="); Console.WriteLine("Example Up Casting And Down Casting"); //Text text = new Text(); //Shape shape = new Shape(); //text.Width = 200; //shape.Width = 100; //Console.WriteLine(text.Width); Shape shape = new Text(); Text text = (Text)shape; Console.ReadKey(); }
private string GetOutputFromTheApp(string[] args) { var fakeConsoleOutput = new StringWriter(); Console.SetOut(fakeConsoleOutput); RateCalculator.Main(args); return(fakeConsoleOutput.ToString()); }
public async Task GivenAnIntegerWhenFizBuzThenProduceString(int input, string expected) { var calculator = new RateCalculator(); var output = await calculator.FizBuz(input); output.Should().Be(expected); }
static void Main(string[] args) { var customer = new Customer(); //Need to move customer class to a separate assembly Amazon.RateCalculator calculator = new RateCalculator(); System.Console.WriteLine(); }
public ProgressForm() { InitializeComponent(); _calculator = new RateCalculator(); this.__timer.Tick += new EventHandler(__timer_Tick); this.VisibleChanged += new EventHandler(ProgressForm_VisibleChanged); }
public void CalcRateTestNightHours() { TaxiRide lod_taxi_ride = new TaxiRide() { state = "New York", miles = 5, minutes = 5, RideTime = DateTime.Parse("10/08/2010 12:30:00 am") }; RateCalculator lod_rate_calculator = new RateCalculator(); Assert.AreEqual((decimal)14.5, lod_rate_calculator.CalcRate(lod_taxi_ride)); }
public void CalcRateTestBaseCase() { TaxiRide lod_taxi_ride = new TaxiRide() { state = "New York", miles = 2, minutes = 5, RideTime = DateTime.Parse("10/08/2010 05:30:00 pm") }; RateCalculator lod_rate_calculator = new RateCalculator(); Assert.AreEqual((decimal)9.75, lod_rate_calculator.CalcRate(lod_taxi_ride)); }
public void CalcRateTestNoNYTax() { TaxiRide lod_taxi_ride = new TaxiRide() { state = "New Jersey", miles = 2, minutes = 5, RideTime = DateTime.Parse("10/08/2010 09:08:00 AM") }; RateCalculator lod_rate_calculator = new RateCalculator(); Assert.AreEqual((decimal)8.25, lod_rate_calculator.CalcRate(lod_taxi_ride)); }
public void CalcRateTestPeakHours() { TaxiRide lod_taxi_ride = new TaxiRide() { state = "New York", miles = 1, minutes = 5, RideTime = DateTime.Parse("10/08/2010 06:00:00 PM") }; RateCalculator lod_rate_calculator = new RateCalculator(); Assert.AreEqual((decimal)8, lod_rate_calculator.CalcRate(lod_taxi_ride)); }
public async Task GivenThreeWhenFizBuzThenFiz() { //AAA //Arrange var calculator = new RateCalculator(); const int input = 3; //Act var output = await calculator.FizBuz(input); //Assert output.Should().Be("Fiz"); }
public void RateCalculator_Calculate_ShouldCalculateRate(decimal baseRate, decimal quoteRate, decimal expected) { var rateCalculator = new RateCalculator(); var baseCurrency = new Currency { Rate = baseRate }; var quoteCurrency = new Currency { Rate = quoteRate }; var actual = rateCalculator.CalculateRate(baseCurrency, quoteCurrency); actual.Should().Be(expected); }
public void Promote() { var calculate = new RateCalculator(); var rating = calculate.Calculate(this); if (rating == 0) { System.Console.WriteLine("Promote logic Change!!!!!!"); } else { System.Console.WriteLine("Game Over"); } }
public ActionResult <RateResult> Get(DateTime entry, DateTime exit) { if (exit < entry) { return(BadRequest()); } var rate = RateCalculator.Calculate(entry, exit); if (rate == null) { return(BadRequest()); } return(Ok(rate)); }
static void Main() { Console.WriteLine("Hello World!"); //access modifiers var customer = new Customer(); Amazon.RateCalculator calculator = new RateCalculator(); //constructors and inheritance var car = new Car("XYZ1234"); //upcasting and downcasting `AS` and `IS` // Text text = new Text(); // Shape shape = text; // text.Width = 200; // shape.Width = 100; // Console.WriteLine(text.Width); StreamReader reader = new StreamReader(new MemoryStream()); //upcasting /* var list = new ArrayList(); * list.Add(1); * list.Add("Mosh"); * list.Add(new Text()); * var anotherList = new List<Shape>(); */ //downcasting Shape shape = new Text(); Text text = (Text)shape; //Boxing / Unboxing var list = new ArrayList(); list.Add(1); list.Add("Art"); list.Add(DateTime.Today); var number = (int)list[1]; var anotherList = new List <int>(); var names = new List <string>(); names.Add("Art"); anotherList.Add(0); }
private decimal CalculateAverageRate(List <Rates_Users_Places> rates) { var averageRate = 0.00m; if (rates.Count > 0) { var fiveCount = rates.Count(x => x.Rate == 5); var fourCount = rates.Count(x => x.Rate == 4); var threeCount = rates.Count(x => x.Rate == 3); var twoCount = rates.Count(x => x.Rate == 2); var oneCount = rates.Count(x => x.Rate == 1); averageRate = RateCalculator.Calculcate(fiveCount, fourCount, threeCount, twoCount, oneCount); } return(averageRate); }
public void Should_Get_Power_Consumption() { string[] binary = new string[] { "00100", "11110", "10110", "10111", "10101", "01111", "00111", "11100", "10000", "11001", "00010", "01010" }; var result = RateCalculator.GetPowerConsumption(binary); Assert.Equal(198, result); }
public void Should_Get_Life_Support_Rating() { string[] binary = new string[] { "00100", "11110", "10110", "10111", "10101", "01111", "00111", "11100", "10000", "11001", "00010", "01010" }; var result = RateCalculator.GetLifeSupportRating(binary); Assert.Equal(230, result); }
static void Main(string[] args) { var customer = new Customer(); Amazon.RateCalculator calculator = new RateCalculator(); }
public void Promote() { var calculator = new RateCalculator(); var rating = calculator.Calculate(this); }
private void LoadData(string id) { try { var idToNumber = int.Parse(id); using (var db = new PointsOfInterestContext()) { var museum = db.Museums.SingleOrDefault(x => x.Id == idToNumber); var currentUser = db.Users.SingleOrDefault(x => x.Email == this.UserEmail); if (museum == null) { throw new ArgumentNullException("Invalid museum Id"); } else { this.Mus = museum; var ratesMus = db.Rates_Users_Museums .Where(x => x.MuseumId == this.Mus.Id).ToList(); var averageRate = 0.0m; if (ratesMus.Count > 0) { var fiveCount = ratesMus.Count(x => x.Rate == 5); var fourCount = ratesMus.Count(x => x.Rate == 4); var threeCount = ratesMus.Count(x => x.Rate == 3); var twoCount = ratesMus.Count(x => x.Rate == 2); var oneCount = ratesMus.Count(x => x.Rate == 1); averageRate = RateCalculator.Calculcate(fiveCount, fourCount, threeCount, twoCount, oneCount); } museum.AverageRate = averageRate; var currentUserRate = db.Rates_Users_Museums .SingleOrDefault(x => x.MuseumId == this.Mus.Id && x.UserId == currentUser.Id); if (currentUserRate != null) { YourRateLabel.Content = "Your rate is : " + currentUserRate.Rate; } AverageRate.Value = (int)Math.Round(averageRate); MusDes.Content = museum.Descripiton; MusName.Content = museum.MuseumName; var dir = System.IO.Directory.GetParent(Environment.CurrentDirectory).ToString(); var path = System.IO.Path.GetDirectoryName(dir); var imagePath = System.IO.Path.Combine(path + "/Images/Museums/" + museum.ImageUrl); //Uri resourceUri = new Uri(imagePath, UriKind.Relative); BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(imagePath); bitmap.EndInit(); MusImg.Source = bitmap; } } } catch { } }
public Ticket InsertCoins(decimal coinSum) { return(new Ticket(coinSum, (int)Math.Floor(coinSum / RateCalculator.CalculateRate()))); }
static void Main(string[] args) { var customer = new Customer(); Amazon.RateCalculator calculator = new RateCalculator();//we are creating dependancy and breaking encapsulation. }
public RateCalculatorTests() { _rateCalculator = new RateCalculator(); }
public void Promote() { var rateCalculator = new RateCalculator(); //Caveat: Its not good to instantiate a new object inside a method here as this creates coupling/dependency to this object. We'll see proper way in Interfaces afterwards var rating = rateCalculator.Calculate(this); }
public RateController(RateCalculator calculator) { _calculator = calculator; }
public RatesController(CargoDb context, DapperCargoDb dapperCargoDb, IConfiguration configuration, RateCalculator rateCalculator) : base(context) { this.dapperCargoDb = dapperCargoDb; this.configuration = configuration; this.rateCalculator = rateCalculator; }
static void Main(string[] args) { var customer = new Customer(); library.RateCalculator rate = new RateCalculator(); }
public ManifestsController(CargoDb context, RateCalculator rateCalculator) : base(context) { this.rateCalculator = rateCalculator; }