Skip to content

Commit

Permalink
small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
MoEssamKhattab committed Sep 29, 2023
1 parent fecbc08 commit 42b22eb
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion ZC-GPA Calculator/AddSemesterForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private void AddSemesterForm_Load(object sender, EventArgs e)

private void addSemesterBtn_Click(object sender, EventArgs e)
{
SemesterTitle = (Semester)Enum.Parse(typeof(Semester) ,this.semesterComboBox.Text);
SemesterTitle = (Semester)Enum.Parse(typeof(Semester), this.semesterComboBox.Text);
SemesterYear = this.yearDatePicker.Value.Year;
this.DialogResult = DialogResult.OK;
}
Expand Down
17 changes: 0 additions & 17 deletions ZC-GPA Calculator/Defs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,4 @@ public enum NonGPAGrades : byte
WF,
TR,
};

// repeated courses

/*
Attempted Hours:
Attempted hours are defined as all hours accumulated throughout a student's career at an institution
(including all passed courses, failed courses, repeated courses, courses dropped after drop-add period, summer courses and transfer work).
Note: Hours currently in progress are not calculated in attempted hours
Earned Hours:
Earned hours are defined as credits attained from all courses (including transfer work, AP classes and summer courses)
a student has successfully passed. Withdrawals and failed courses do not count as earned hours.
Note: Hours currently in progress are not calculated in earned hours
*/
}
5 changes: 2 additions & 3 deletions ZC-GPA Calculator/Form1.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Security.Policy;

namespace ZC_GPA_Calculator
{
Expand Down Expand Up @@ -31,7 +30,7 @@ private void browseFileBtn_Click(object sender, EventArgs e)

if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string filePath = openFileDialog.FileName; //files path
string filePath = openFileDialog.FileName;
readInputFile(filePath);
}
}
Expand Down Expand Up @@ -89,7 +88,7 @@ private void addNewSemester(Semester semesterTitle, int year, BindingList<semest

initializeSemesterCardEvents(semesterCard);

semesterCard.SemesterTitle = $"{semesterTitle.ToString()}, {year}";
semesterCard.SemesterTitle = $"{semesterTitle} {year}";
semestersPanel.Controls.Add(semesterCard);
semesterCardList.Add(semesterCard);
}
Expand Down
9 changes: 7 additions & 2 deletions ZC-GPA Calculator/SemesterCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial class SemesterCard : UserControl
bool allowEditing = false;
bool allowAdding = false;
BindingList<string> letterGrades;
static int maxVisibleCourses = 6;
const int maxVisibleCourses = 6;
public string SemesterTitle { get => semesterTitle.Text; set => semesterTitle.Text = value; }
public bool AllowAdding { get => allowAdding; set => allowAdding = value; }

Expand All @@ -17,7 +17,6 @@ public SemesterCard()
InitializeComponent();
letterGrades = new BindingList<string> { "A", "A-", "B+", "B", "B-", "C+", "C", "C-", "F" };
this.grade.DataSource = letterGrades;

}
private void SemesterCard_Load(object sender, EventArgs e)
{
Expand Down Expand Up @@ -116,6 +115,12 @@ public void updateGPACalculationsTable(BindingList<semester> semesters, int inde
// GPA Calculations
calculationsTable.Rows[0].Cells["GPACredits"].Value = semesters[index].calculateGPACredits().ToString();
calculationsTable.Rows[1].Cells["GPACredits"].Value = semester.calculateOverallGPACredits(semesters, index).ToString();
calculationsTable.Rows[0].Cells["AttemptedCredits"].Value = semesters[index].calculateAttemptedCredits().ToString();
calculationsTable.Rows[1].Cells["AttemptedCredits"].Value = semester.calculateOverallAttemptedCredits(semesters, index).ToString();
calculationsTable.Rows[0].Cells["EarnedCredits"].Value = semesters[index].calculateEarnedCredits().ToString();
calculationsTable.Rows[1].Cells["EarnedCredits"].Value = semester.calculateOverallEarnedCredits(semesters, index).ToString();
calculationsTable.Rows[0].Cells["TotalCredits"].Value = semesters[index].calculateTotalCredits().ToString();
calculationsTable.Rows[1].Cells["TotalCredits"].Value = semester.calculateOverallTotalCredits(semesters, index).ToString();
calculationsTable.Rows[0].Cells["TransferCredits"].Value = semesters[index].calculateTransferCredits().ToString();
calculationsTable.Rows[1].Cells["TransferCredits"].Value = semester.calculateOverallTransferCredits(semesters, index).ToString();
calculationsTable.Rows[0].Cells["Quality_Points"].Value = semesters[index].calculateQualityPoints().ToString("0.00");
Expand Down
2 changes: 0 additions & 2 deletions ZC-GPA Calculator/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//using iTextSharp.text.pdf.parser;
using System.Net;
using System.ComponentModel;
using System;

namespace ZC_GPA_Calculator
{
Expand Down Expand Up @@ -130,7 +129,6 @@ public static void changeRepeatedFlag(string courseCode, BindingList<semester> s
{
MessageBox.Show($"It seems that the repeated course, {courseCode}, was repeated with different corse code. Reach the old course and change its grade to 'P', please!");
}

}
public static void changeRepeatedFlag2(string courseCode, BindingList<semester> semestersList)
{
Expand Down
Binary file not shown.
Binary file modified ZC-GPA Calculator/bin/Debug/net7.0-windows/ZC-GPA Calculator.pdb
Binary file not shown.
Binary file not shown.
Binary file modified ZC-GPA Calculator/obj/Debug/net7.0-windows/ZC-GPA Calculator.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
29 changes: 26 additions & 3 deletions ZC-GPA Calculator/semester.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System.Diagnostics;


namespace ZC_GPA_Calculator
Expand Down Expand Up @@ -70,25 +71,47 @@ public double calculateEarnedCredits()
double _credits = 0;
foreach (var course in this.courses)
{
if (course.Grade != "IP" && course.Grade != "" &&)
//if ((course.Grade == "A" || course.Grade == "A-" || course.Grade == "B+" || course.Grade == "B" || course.Grade == "B-" || course.Grade == "C+" || course.Grade == "C" || course.Grade == "C-" || course.Grade == "P" || course.Grade == "TR") && course.RepeatedIn == -1)
// ===
if ((course.GpaCredits != 0 || course.Grade == "P" || course.Grade == "TR") && course.RepeatedIn == -1)
_credits += course.Credits;
}
return _credits;
}
public static double calculateOverallEarnedCredits(BindingList<semester> semesters, int index)
{
double _overallCredits = 0;

for (int i = 0; i <= index; i++)
{
foreach (var course in semesters[i].Courses)
{
if (course.Grade != "IP")
if ((course.GpaCredits != 0 || course.Grade == "P" || course.Grade == "TR") && course.RepeatedIn == -1)
_overallCredits += course.Credits;
}
}
return _overallCredits;
}
public double calculateTotalCredits()
{
double _credits = 0;
foreach (var course in this.courses)
{
_credits += course.Credits;
}
return _credits;
}
public static double calculateOverallTotalCredits(BindingList<semester> semesters, int index)
{
double _overallCredits = 0;
for (int i = 0; i <= index; i++)
{
foreach (var course in semesters[i].Courses)
{
_overallCredits += course.Credits;
}
}
return _overallCredits;
}
public double calculateTransferCredits()
{
double _credits = 0;
Expand Down

0 comments on commit 42b22eb

Please sign in to comment.