Guest User

Untitled

a guest
May 24th, 2018
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.03 KB | None | 0 0
  1. //------------------------------------------------------------------------------
  2. // UNIVERSIDAD INTERAMERICANA PARA EL DESARROLLO
  3. //
  4. // Programador: Julio César Sosa Yeladaqui
  5. //
  6. // Descripción: Programa que crea un objeto simulando una tarjeta de credito.
  7. //
  8. // Fecha: 24 de Septiembre de 2008
  9. //------------------------------------------------------------------------------
  10.  
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Text;
  14.  
  15. namespace ejemplo_tarjeta
  16. {
  17. class Program
  18. {
  19. public class Tarjeta
  20. {
  21. //Datos, Atributos, Propiedades
  22. public
  23. int saldo;
  24. string saldo1;
  25. int credito;
  26. string credito1;
  27. int gasto;
  28. string gasto1;
  29. int ingreso;
  30. string ingreso1;
  31.  
  32. //Constructor
  33. public Tarjeta()
  34. {
  35.  
  36. Console.WriteLine("¿Cuanto es el SALDO que desea Asignar?:");
  37. saldo1 = Console.ReadLine();
  38. saldo = Int32.Parse(saldo1);
  39.  
  40. Console.WriteLine("¿Cuanto es el Credito que desea Asignar?:");
  41. credito1 = Console.ReadLine();
  42. credito = Int32.Parse(credito1);
  43.  
  44. }
  45. //----METODOS------------------------------------
  46. public int Saldo()
  47. {
  48.  
  49. return saldo;
  50.  
  51. }
  52.  
  53. public int Credito()
  54. {
  55.  
  56. return credito;
  57.  
  58. }
  59.  
  60. public void Comprar()
  61. {
  62.  
  63. Console.WriteLine("¿Cuanto cuesta el producto que desea comprar?:");
  64. gasto1 = Console.ReadLine();
  65.  
  66. gasto = Int32.Parse(gasto1);
  67.  
  68. if (saldo >= gasto)
  69. {
  70.  
  71. saldo -= gasto;
  72.  
  73. }
  74. else
  75. {
  76.  
  77. if (credito >= gasto)
  78. {
  79. saldo -= gasto;
  80. saldo *= -1;
  81. credito -= saldo;
  82.  
  83. saldo = 0;
  84.  
  85. }
  86. else
  87. {
  88.  
  89. Console.WriteLine("Usted ha sobre pasado su credito.");
  90. Console.WriteLine("La compra no pudo realizarse.");
  91.  
  92. }
  93.  
  94. }
  95.  
  96.  
  97. }
  98.  
  99. public int Deuda()
  100. {
  101.  
  102. return 25000 - credito;
  103.  
  104. }
  105.  
  106. public void Deposito()
  107. {
  108.  
  109. Console.WriteLine("¿Cuanto desea depositar a su tarjeta?:");
  110. ingreso1 = Console.ReadLine();
  111.  
  112. ingreso = Int32.Parse(ingreso1);
  113.  
  114. saldo += ingreso;
  115.  
  116.  
  117. }
  118.  
  119.  
  120. }
  121.  
  122. static void Main(string[] args)
  123. {
  124. int valor;
  125. string valor2;
  126. bool ciclo = true;
  127.  
  128. //Tarjeta visa = new Tarjeta();
  129.  
  130. Tarjeta visa = null;
  131.  
  132. while (ciclo)
  133. {
  134.  
  135. Console.WriteLine("Crear Tarjeta de Credito: 1");
  136. Console.WriteLine("Verificar Saldo: 2");
  137. Console.WriteLine("Verificar Credito: 3");
  138. Console.WriteLine("Realizar una Compra: 4");
  139. Console.WriteLine("Verificar Deuda: 5");
  140. Console.WriteLine("Realizar un deposito a la tarjeta: 6");
  141. Console.WriteLine("Salir: 7");
  142. Console.WriteLine("¿Que opcion desea realizar:?");
  143.  
  144. valor2 = Console.ReadLine();
  145.  
  146. valor = Int32.Parse(valor2);
  147.  
  148.  
  149. switch (valor)
  150. {
  151. case 1:
  152. Console.Clear();
  153. visa = new Tarjeta();
  154. break;
  155. case 2:
  156. Console.Clear();
  157. Console.WriteLine(visa.Saldo());
  158. break;
  159. case 3:
  160. Console.Clear();
  161. Console.WriteLine(visa.Credito());
  162. break;
  163. case 4:
  164. Console.Clear();
  165. visa.Comprar();
  166. break;
  167. case 5:
  168. Console.Clear();
  169. Console.WriteLine(visa.Deuda());
  170. break;
  171. case 6:
  172. Console.Clear();
  173. visa.Deposito();
  174. break;
  175. case 7:
  176. Console.Clear();
  177. ciclo = false;
  178. break;
  179. default:
  180. Console.Clear();
  181. Console.WriteLine("Opción no Valida.");
  182. break;
  183.  
  184. }
  185.  
  186. }
  187.  
  188. }
  189.  
  190. }
  191. }
Add Comment
Please, Sign In to add comment