Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SoftuniSv
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Enter number of packets: ");
- int n = int.Parse(Console.ReadLine());
- Packet[] packets = new Packet[n];
- for (int i = 0; i < n; i++)
- {
- Console.Write("Enter msg: ");
- string msg = Console.ReadLine();
- Console.Write("Enter packet number: ");
- int num = int.Parse(Console.ReadLine());
- packets[i] = new Packet(msg, num);
- }
- for (int i = 0; i < packets.Length; i++)
- {
- Console.Write(packets[i]);
- }
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SoftuniSv
- {
- public class Packet
- {
- private string msg;
- private int number;
- public Packet(string msg, int number)
- {
- this.msg = msg;
- this.number = number;
- }
- public override string ToString()
- {
- return this.Msg;
- }
- public string Msg
- {
- get
- {
- return this.msg;
- }
- }
- public int Number
- {
- get
- {
- return this.number;
- }
- }
- public double Losses
- {
- get
- {
- int count = 0;
- for (int i = 0; i < msg.Length; i++)
- {
- if (msg[i] == '-')
- {
- count++;
- }
- }
- return (double)count / msg.Length;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement