Advertisement
cuniszkiewicz

Student

Apr 26th, 2025
190
0
29 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace OOP_1N122L_grafika_lato_2025
  8. {
  9.     internal class Student
  10.     {
  11.         //pola
  12.         public string imie;
  13.         public string nazwisko;
  14.         private int wiek;
  15.         private double sredniaOcen;
  16.  
  17.         //metody
  18.         public void PrzedstawSie()
  19.         {
  20.             Console.WriteLine($"Student: {imie} {nazwisko}, " +
  21.                     $"wiek: {wiek}, średnia: {sredniaOcen}.");
  22.         }
  23.  
  24.         public void ZdajEgzamin(string przedmiot, double ocena)
  25.         {
  26.             Console.WriteLine($"Student zdał egazmin z przedniotu: {przedmiot} na ocenę: {ocena}.");
  27.  
  28.         }
  29.  
  30.         public double JakaOcena(int procenty)
  31.         {
  32.             double ocena = 2.0;
  33.             if (procenty < 50 || procenty > 100)
  34.                 ocena = 2.0;
  35.             if (procenty >= 50 && procenty < 75)
  36.                 ocena = 3.0;
  37.             if (procenty >= 75 && procenty < 80)
  38.                 ocena = 3.5;
  39.             if (procenty >= 80 && procenty < 85)
  40.                 ocena = 4.0;
  41.             if (procenty >= 85 && procenty < 90)
  42.                 ocena = 4.5;
  43.             if (procenty >= 90 && procenty <= 100)
  44.                 ocena = 5.0;
  45.  
  46.             return ocena;
  47.        
  48.         }
  49.  
  50.         public void UstawWiek(int _wiek)
  51.         {
  52.             if (_wiek > 17)
  53.                 wiek = _wiek;
  54.             else
  55.                 wiek = 19;
  56.         }
  57.         public void UstawSredniaOcen(double _srednia)
  58.         {
  59.             if (_srednia >= 3 && _srednia <= 5)
  60.                 sredniaOcen = _srednia;
  61.             else
  62.                 sredniaOcen = 3;
  63.         }
  64.  
  65.         public int PokazWiek()
  66.         { return wiek; }
  67.  
  68.         public double PokazSredniaOcen()
  69.         { return sredniaOcen; }
  70.     }
  71. }//następnym razem konstruktory i właściwości
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement