Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 474.2k

How to implement coin jar in c# using Rest API?

Oct 14 2020 2:48 AM
Hi Team
 
I need some help with my requirement to implement coin jar in c# using rest api. My requirement are as below;
 
"coin jar only accept latest us coinage, must have volume of 42 fluids ounces"
"must have a counter to keep track of the total amount of money collected"
"reset the count back to $0.00."
 
My logic so far is as follows in c# using rest api
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Net;  
  5. using System.Net.Http;  
  6. using System.Web.Http;  
  7.   
  8. namespace CoinJarAPI.Controllers  
  9. {  
  10.     public class CoinJarController : ApiController  
  11.     {  
  12.         // GET: api/CoinJar  
  13.         public IEnumerable<string> Get()  
  14.         {  
  15.             return new string[] { "value1""value2" };  
  16.         }  
  17.   
  18.         // GET: api/CoinJar/5  
  19.         public string Get(int id)  
  20.         {  
  21.             return "value";  
  22.         }  
  23.   
  24.         // POST: api/CoinJar  
  25.         public void Post([FromBody]string value)  
  26.         {  
  27.         }  
  28.   
  29.         // PUT: api/CoinJar/5  
  30.         public void Put(int id, [FromBody]string value)  
  31.         {  
  32.         }  
  33.   
  34.         // DELETE: api/CoinJar/5  
  35.         public void Delete(int id)  
  36.         {  
  37.         }  
  38.     }  
  39. }  
  40.   
  41. using System;  
  42. using System.Collections.Generic;  
  43. using System.Linq;  
  44. using System.Text;  
  45. using System.Threading.Tasks;  
  46.   
  47. namespace CoinJarAPI.Interface  
  48. {  
  49.     interface ICoinJar  
  50.     {  
  51.         void AddCoin(ICoin coin);  
  52.         decimal GetTotalAmount();  
  53.         void Reset();  
  54.     }  
  55.   
  56.     public interface ICoin  
  57.     {  
  58.         decimal Amount { getset; }  
  59.         decimal Volume { getset; }  
  60.     }  
  61. }  
  62.   
  63. using CoinJarAPI.Interface;  
  64. using System;  
  65. using System.Collections.Generic;  
  66. using System.Linq;  
  67. using System.Web;  
  68.   
  69. namespace CoinJarAPI.Repository  
  70. {  
  71.     public class Repository : ICoinJar  
  72.     {  
  73.         public void AddCoin(ICoin coin)  
  74.         {  
  75.             throw new NotImplementedException();  
  76.         }  
  77.   
  78.         public decimal GetTotalAmount()  
  79.         {  
  80.             throw new NotImplementedException();  
  81.         }  
  82.   
  83.         public void Reset()  
  84.         {  
  85.             throw new NotImplementedException();  
  86.         }  
  87.     }  
  88. }  
 
 

Answers (6)