# Assignment_01_Rational - Dohyun Kim - Hiep Ngo.pdf - 1 2 3...

• 1
• 100% (5) 5 out of 5 people found this document helpful

This preview shows page 1 out of 1 page.

/** 1 * COMP123 Section 006 - Summer 2020 2 * Assignment #1 3 * Dohyun Kim 301058465 4 * Hiep Ngo 301121528 5 */ 6 7 using System; 8 9 namespace COMP123.Assignment01 10 { 11 public class Rational 12 { 13 public int Denominator { get ; private set ; } 14 public int Numerator { get ; private set ; } 15 16 public Rational ( int numerator = 0 , int denominator = 1 ) 17 { 18 Numerator = numerator ; 19 Denominator = denominator ; 20 } 21 22 public override string ToString () 23 { 24 return \$" { Numerator } / { Denominator } " ; 25 } 26 27 public void IncreaseBy ( Rational other ) 28 { 29 int newDenom = Denominator * other . Denominator ; 30 int newNumer = ( Numerator * other . Denominator ) + ( other . Numerator * Denominator ); 31 Denominator = newDenom; 32 Numerator = newNumer; 33 } 34 35 public void DecreaseBy ( Rational other ) 36 { 37 int newDenom = Denominator * other . Denominator ; 38