示例#1
0
$students['j123'] = $first;
// add a second student
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
// add a third student
$third = new Student();
$third->surname = "Wubs";
$third->first_name = "Rosanna";
$third->add_email('home', '*****@*****.**');
$third->add_grade(100);
$third->add_grade(100);
$third->add_grade(100);
$students['a000'] = $third;
// sort the students in the array via id
ksort($students);
// display students
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>
示例#2
0
//initialize the second Student
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
//initialize the third Student
$third = new Student();
$third->surname = "Ensom";
$third->first_name = "James";
$third->add_email('home', '*****@*****.**');
$third->add_email('work1', '*****@*****.**');
$third->add_grade(92);
$third->add_grade(88);
$third->add_grade(54);
$students['t789'] = $third;
//sort the Students
ksort($students);
//print out the Students using the toString method
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>
示例#3
0
文件: index.php 项目: JWongBCIT/Lab1
//Create second student and add info
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
//Add myself as a student
$third = new Student();
$third->surname = "Wong";
$third->first_name = "Jason";
$third->add_email('home', '*****@*****.**');
$third->add_email('work', '*****@*****.**');
$third->add_grade(95);
$third->add_grade(95);
$third->add_grade(98);
$students['j987'] = $third;
//Sort the students
ksort($students);
//Print all students
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>
示例#4
0
文件: index.php 项目: askho/labs
//Creating the second student
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
//Creating the third student
$third = new Student();
$third->surname = "Parry";
$third->first_name = "Jim";
$third->add_grade(0);
$third->add_grade(40);
$third->add_email('work', '*****@*****.**');
//Add to array and sort
$students = array();
$students['j123'] = $first;
$students['a456'] = $second;
$students["b212"] = $third;
ksort($students);
//Display the students
foreach ($students as $student) {
    echo $student->toString();
}
?>
     </body>
 </html>
示例#5
0
// Adding the Second Student
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
// Adding a third Student, myself!
$third = new Student();
$third->surname = "Yiu";
$third->first_name = "Julia";
$third->add_email('home', '*****@*****.**');
$third->add_email('work', '*****@*****.**');
$third->add_grade(90);
$third->add_grade(75);
$third->add_grade(90);
$students['a009'] = $third;
// A sort function that sorts an array by key. In this case, it is
// sorting the Students array.
ksort($students);
// A for-each loop that prints out each student entered
// in the array of students
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
$first->add_grade(55);
$students['j123'] = $first;
/*adding a second student*/
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
/*adding a myself*/
$third = new Student();
$third->surname = "Dobrianskaia";
$third->first_name = "Nadia";
$third->add_email('work', '*****@*****.**');
$third->add_grade(95);
$third->add_grade(80);
$students['n789'] = $third;
/*sort the student order*/
ksort($students);
/*displaying the students*/
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>
示例#7
0
$first->add_grade(55);
$students['j123'] = $first;
//creates a second student
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
//creates a third student
$third = new Student();
$third->surname = "Langaditis";
$third->first_name = "Speridon";
$third->add_email('home', '*****@*****.**');
$third->add_grade(100);
$third->add_grade(100);
$students['s789'] = $third;
//sorts the students alphabetically
ksort($students);
//displays all the students
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>
示例#8
0
$students['j123'] = $first;
$second = new Student();
// adds second student
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
$third = new Student();
// adds third student
$third->surname = "Tangeman";
$third->first_name = "Kevin";
$third->add_email('home', '*****@*****.**');
$third->add_email('work', '*****@*****.**');
$third->add_grade(90);
$third->add_grade(80);
$students['k789'] = $third;
ksort($students);
// one of the many sort functions
foreach ($students as $student) {
    // displays each student in the array
    echo $student->toString();
}
?>
    </body>
</html>
示例#9
0
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
/**
 * Adds the third student (Myself) and defines it's properties
 */
$third = new Student();
$third->surname = "Zhou";
$third->first_name = "Becky";
$third->add_email('home', '*****@*****.**');
$third->add_email('work', '*****@*****.**');
$third->add_email('school', '*****@*****.**');
$third->add_grade(100);
$third->add_grade(50);
$third->add_grade(60);
$students['b789'] = $third;
/**
 * Sorts students in alphabetical order
 */
ksort($students);
/**
 * Displays all students
 */
foreach ($students as $student) {
    echo $student->toString();
示例#10
0
$first->add_email('home', '*****@*****.**');
$first->add_email('work', '*****@*****.**');
$first->add_grade(65);
$first->add_grade(75);
$first->add_grade(55);
$students['j123'] = $first;
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(85);
$second->add_grade(90);
$second->add_grade(50);
$students['a456'] = $second;
$third = new Student();
$third->surname = "Tekenos";
$third->first_name = "Jessica";
$third->add_email('home', '*****@*****.**');
$third->add_email('school', '*****@*****.**');
$third->add_grade(97);
$third->add_grade(88);
$third->add_grade(67);
$students['j514'] = $third;
//sorts students
ksort($students);
//displays each student object in the array
foreach ($students as $student) {
    echo $student->toString();
}
示例#11
0
//Student 2
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
//Student 3
$third = new Student();
$third->surname = "Wong";
$third->first_name = "Evanna";
$third->add_email('home', '*****@*****.**');
$third->add_grade(80);
$third->add_grade(84);
$third->add_grade(70);
$students['e789'] = $third;
//sort student array
ksort($students);
// one of the many sort functions
//print array
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>
示例#12
0
//Add second student
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
//Add third student
$third = new Student();
$third->surname = "Huang";
$third->first_name = "Vincent";
$third->add_email('home', '*****@*****.**');
$third->add_email('work', '*****@*****.**');
$third->add_grade(99);
$third->add_grade(99);
$third->add_grade(99);
$students['v123'] = $third;
//Sort the student list
ksort($students);
//Print students
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>
示例#13
0
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
//add the second student to the array
$students['a456'] = $second;
//create the third student
$third = new Student();
$third->surname = "Pearen";
$third->first_name = "Jonny";
$third->add_email('personal', '*****@*****.**');
$third->add_grade(90);
$third->add_grade(80);
$third->add_grade(70);
//add the third student to the array
$students['p789'] = $third;
//sort the students by key
ksort($students);
// one of the many sort functions
//echo each student in the students array using the toString method
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>
示例#14
0
    <body>
      <?php 
include 'student.php';
$students = array();
foreach ($students as $student) {
    echo $student->toString();
}
$first = new Student();
$first->surname = "Doe";
$first->first_name = "John";
$first->add_email('home', '*****@*****.**');
$first->add_email('work', '*****@*****.**');
$first->add_grade(65);
$first->add_grade(75);
$first->add_grade(55);
$students['j123'] = $first;
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
ksort($students);
?>
    </body>
</html>
示例#15
0
// Create Duy
$student2 = new Student();
$student2->surname = "Le";
$student2->first_name = "Duy";
$student2->add_email('home', '*****@*****.**');
$student2->add_email('work', '*****@*****.**');
$student2->add_grade(10);
$student2->add_grade(8);
$student2->add_grade(9);
// Add Duy to array of students
$students['duy'] = $student2;
// Create Jens
$student3 = new Student();
$student3->surname = "Christiansen";
$student3->first_name = "Jens";
$student3->add_email('home', '*****@*****.**');
$student3->add_email('work', '*****@*****.**');
$student3->add_grade(100);
$student3->add_grade(89);
$student3->add_grade(99);
// Add Jens to array of students
$students['jens'] = $student3;
// sort by key
ksort($students);
// Print each student
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>
示例#16
0
$students['j123'] = $first;
//Creating 2nd student and adding it to the students array
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
//Creating 3rd student and adding it to the students array
$third = new Student();
$third->surname = "Sarmiento";
$third->first_name = "Lawrence";
$third->add_email('work', '*****@*****.**');
$third->add_grade(100);
$third->add_grade(50);
$third->add_grade(1);
$students['a123'] = $third;
//sort the students array before displaying the students
ksort($students);
//Display each student in the students array
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>
示例#17
0
$first->add_grade(55);
$students['j123'] = $first;
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
$myself = new Student();
$myself->surname = "Becker";
$myself->first_name = "Gerald";
$myself->add_email('home', '*****@*****.**');
$myself->add_email('work1', '*****@*****.**');
$myself->add_email('work2', '*****@*****.**');
$myself->add_grade(77);
$myself->add_grade(99);
$myself->add_grade(85);
$students['g00900309'] = $myself;
ksort($students);
?>
        
        <h1>List of Students</h1>
        <hr>
        <?php 
//print all the students
foreach ($students as $student) {
    echo $student->toString();
示例#18
0
$first->add_grade(55);
$students['j123'] = $first;
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
$third = new Student();
$third->surname = "Carpenter";
$third->first_name = "Wilson";
$third->add_email("work", "*****@*****.**");
$third->add_grade(90);
$third->add_grade(97);
$third->add_grade(85);
$third->add_grade(77.5);
$students['w987'] = $third;
//Sort the students by key
ksort($students);
//Display the students and their information
foreach ($students as $s) {
    echo $s->toString();
}
?>
    </body>
</html>
示例#19
0
$first->add_grade(75);
$first->add_grade(55);
$students['j123'] = $first;
//Student two
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
//Student three
$third = new Student();
$third->surname = "Arumugam";
$third->first_name = "Jathavan";
$third->add_email('home', '*****@*****.**');
$third->add_grade(95);
$students['A444'] = $third;
ksort($students);
// one of the many sort functions
//Print all the available students
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>
示例#20
0
//email with key as work2
$second->add_email('work2', '*****@*****.**');
//call Student add_grade function
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
//Adding $first to array with key 'a456'
$students['a456'] = $second;
//Instantiating a Student
$second = new Student();
//Set student surname to 'Chau'
$second->surname = "Chau";
//Set student first name to 'Bryan'
$second->first_name = "Bryan";
//email with key as Home
$second->add_email('home', '*****@*****.**');
//call Student add_grade function
$second->add_grade(95);
$second->add_grade(100);
$second->add_grade(98);
//Adding $first to array with key 'b123'
$students['b123'] = $second;
//Function to sort student array alphabetically via first name
ksort($students);
/* 
 * A foreach loop that calls the toString method of the 
 * student class for each student in the students array.
 */
foreach ($students as $student) {
    echo $student->toString();
}
示例#21
0
$first->add_grade(55);
$students['j123'] = $first;
//initialize and add second student to array
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
//initialize and add third student to array
$third = new Student();
$third->surname = "Goncharov";
$third->first_name = "Dima";
$third->add_email('work', '*****@*****.**');
$third->add_grade(100);
$third->add_grade(100);
$students['d008'] = $third;
//sort student array by key
ksort($students);
//prints each student out using toString() method
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>
示例#22
0
文件: index.php 项目: psarang/lab1
$first->add_grade(65);
$first->add_grade(75);
$first->add_grade(55);
$students['j123'] = $first;
$second = new Student();
$second->surname = "Einstein";
$second->first_name = "Albert";
$second->add_email('home', '*****@*****.**');
$second->add_email('work1', '*****@*****.**');
$second->add_email('work2', '*****@*****.**');
$second->add_grade(95);
$second->add_grade(80);
$second->add_grade(50);
$students['a456'] = $second;
$third = new Student();
$third->first_name = "P";
$third->surname = "S";
$third->add_email('home', '*****@*****.**');
$third->add_email('school', '*****@*****.**');
$third->add_grade(90);
$third->add_grade(80);
$third->add_grade(88);
$students['p789'] = $third;
ksort($students);
foreach ($students as $student) {
    echo $student->toString();
}
?>
    </body>
</html>