This commit is contained in:
louiscklaw
2025-01-31 19:15:17 +08:00
parent 09adae8c8e
commit 6c60a73f30
1546 changed files with 286918 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
import Foundation
class Student{
var classId:String
var studentId:String
init(classId:String, studentId: String) {
self.classId = classId
self.studentId = studentId
}
}
var students = Array<Student>()
let totalStudent = Int.random(in: 30...100)
let totalClass: Int = Int(ceil((Double(totalStudent) / 30)))
func generateStudentId() -> String{
let year = "20"
let campusCode = "03"
let randomDigit: Int = Int.random(in: 0...99999)
return year + campusCode + String(format: "%05d", randomDigit)
}
func checkDuplicate(studentId:String) -> Bool{
var duplicate = false
for student in students{
if student.studentId == studentId{
duplicate = true
break
}
}
return duplicate
}
var distriClass:Int = 1
for count in 1...totalStudent{
var studentId: String
var student: Student
repeat{
studentId = generateStudentId()
}while checkDuplicate(studentId: studentId)
student = Student(classId:String(distriClass), studentId: studentId)
students.append(student)
if distriClass == totalClass {
distriClass = 0
}
distriClass += 1
}
print("Total Student: " + String(totalStudent))
print("Total Class: " + String(totalClass))
print("--------------------------------------------------------")
for student in students{
print("Class: " + student.classId + ", Student ID: " + student.studentId)
}

View File

@@ -0,0 +1,22 @@
# ITE3101-EAAssignment
IT114210 Multimedia and Virtual Reality - Introduction to Programming (SWIFT) - Exam Project
- [x] The total number of each class must not greater than 30 students.
- [x] The total number of new coming years students are randomly between 30 and 100
- [x] Student ID cannot be duplicate.
- [x] Student ID should follow this format: [Year (last 2 digit of the coming academic year) - Campus Code (2 digits) - Random 5 digits (5 digits)]
Campus Code is “03”
- [x] Print out the list of the student as below:
```
Total Student: 51
Total Class: 2
-----------------------------------------
Class: 1, Student ID: 200372486
Class: 2, Student ID: 200350979
Class: 1, Student ID: 200320439
Class: 2, Student ID: 200310247
...
Class: 1, Student ID: 200341498
Class: 2, Student ID: 200356316
```