nucLeaRsc2

C# Lab 7 Problema 1 (Struct to Class! Important)

Nov 16th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace SuportLaborator7
  7. {
  8.     public enum AccountType { Cec, Deposit }
  9.     public class BankAccount
  10.     {
  11.         private AccountType accType;
  12.         private long accNumber;
  13.         private decimal amount;
  14.         public void PopulareCampuri(long nr, decimal sold, AccountType tip)
  15.         {
  16.             accType = tip;
  17.             accNumber = nr;
  18.             amount = sold;
  19.         }
  20.         public long NumarCont()
  21.         {
  22.             return accNumber;
  23.         }
  24.         public decimal Sold()
  25.         {
  26.             return amount;
  27.         }
  28.         public AccountType ReturnTipCont()
  29.         {
  30.             return accType;
  31.         }
  32.     }
  33.  
  34.     class Program
  35.     {
  36.         static void Main(string[] args)
  37.         {
  38.             BankAccount account = new BankAccount();
  39.  
  40.             /*account.accType = AccountType.Cec;
  41.             account.amount = 0.8M;
  42.  
  43.             Console.WriteLine("Introduceti numarul de cont: ");
  44.             account.accNumber = long.Parse(Console.ReadLine());
  45.             */
  46.  
  47.             BankAccount obj = new BankAccount();
  48.             long x = long.Parse(Console.ReadLine());
  49.             obj.PopulareCampuri(x, 3.5M, AccountType.Deposit);
  50.  
  51.             Console.WriteLine("Contul meu are numarul {0}, este de tip {1} si are o suma de {2}",
  52.                 obj.NumarCont(), obj.ReturnTipCont(), obj.Sold());
  53.  
  54.             Console.ReadKey();
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment