Initial Commit
This commit is contained in:
BIN
Source Code/Assignment2/info/A2-StudentFiles.zip
Normal file
BIN
Source Code/Assignment2/info/A2-StudentFiles.zip
Normal file
Binary file not shown.
37
Source Code/Assignment2/info/A2-StudentFiles/Course.java
Normal file
37
Source Code/Assignment2/info/A2-StudentFiles/Course.java
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
This class represents a Course.
|
||||
@author Leah Bidlake
|
||||
*/
|
||||
|
||||
public class Course{
|
||||
|
||||
//Instance variables:
|
||||
//For each Course object, store its name, semester, year, and the
|
||||
//number of students enrolled in the course so far.
|
||||
private String name;
|
||||
private String semester;
|
||||
private int year;
|
||||
private int students;
|
||||
|
||||
|
||||
//The constructor creates a new Course object and initializes the
|
||||
//instance variables.
|
||||
public Course(String nameIn, String semesterIn, int yearIn){
|
||||
name = nameIn;
|
||||
semester = semesterIn;
|
||||
year = yearIn;
|
||||
students = 0; //no students have been added to the course
|
||||
}
|
||||
|
||||
//This is a method that we can call on a Course object
|
||||
//(Specifically, it is an accessor method). This method
|
||||
//creates and returns a String containing all the information
|
||||
//about the state of the object.
|
||||
public String toString(){
|
||||
return name +
|
||||
" offered " + semester +
|
||||
" " + year +
|
||||
" Students: " + students;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/**
|
||||
This is an example of a driver class; its purpose
|
||||
is to try out the Course class.
|
||||
@author Leah Bidlake
|
||||
*/
|
||||
|
||||
public class CourseDriver{
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
//Create some Course objects
|
||||
Course course1 = new Course("CS1073", "Fall", 2020);
|
||||
Course course2 = new Course("CS1083", "Winter", 2021);
|
||||
Course course3 = new Course("MATH1013", "Summer", 2021);
|
||||
|
||||
|
||||
//Now I can print out my courses to confirm they
|
||||
//were created properly
|
||||
System.out.println("course1: " + course1.toString());
|
||||
System.out.println("course2: " + course2.toString());
|
||||
System.out.println("course3: " + course3.toString());
|
||||
|
||||
}
|
||||
|
||||
}
|
BIN
Source Code/Assignment2/info/CS1073-Assign2-F2020.pdf
Normal file
BIN
Source Code/Assignment2/info/CS1073-Assign2-F2020.pdf
Normal file
Binary file not shown.
BIN
Source Code/Assignment2/info/ExampleFiles/Course.class
Normal file
BIN
Source Code/Assignment2/info/ExampleFiles/Course.class
Normal file
Binary file not shown.
37
Source Code/Assignment2/info/ExampleFiles/Course.java
Normal file
37
Source Code/Assignment2/info/ExampleFiles/Course.java
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
This class represents a Course.
|
||||
@author Leah Bidlake
|
||||
*/
|
||||
|
||||
public class Course{
|
||||
|
||||
//Instance variables:
|
||||
//For each Course object, store its name, semester, year, and the
|
||||
//number of students enrolled in the course so far.
|
||||
private String name;
|
||||
private String semester;
|
||||
private int year;
|
||||
private int students;
|
||||
|
||||
|
||||
//The constructor creates a new Course object and initializes the
|
||||
//instance variables.
|
||||
public Course(String nameIn, String semesterIn, int yearIn){
|
||||
name = nameIn;
|
||||
semester = semesterIn;
|
||||
year = yearIn;
|
||||
students = 0; //no students have been added to the course
|
||||
}
|
||||
|
||||
//This is a method that we can call on a Course object
|
||||
//(Specifically, it is an accessor method). This method
|
||||
//creates and returns a String containing all the information
|
||||
//about the state of the object.
|
||||
public String toString(){
|
||||
return name +
|
||||
" offered " + semester +
|
||||
" " + year +
|
||||
" Students: " + students;
|
||||
}
|
||||
|
||||
}
|
BIN
Source Code/Assignment2/info/ExampleFiles/CourseDriver.class
Normal file
BIN
Source Code/Assignment2/info/ExampleFiles/CourseDriver.class
Normal file
Binary file not shown.
25
Source Code/Assignment2/info/ExampleFiles/CourseDriver.java
Normal file
25
Source Code/Assignment2/info/ExampleFiles/CourseDriver.java
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
This is an example of a driver class; its purpose
|
||||
is to try out the Course class.
|
||||
@author Leah Bidlake
|
||||
*/
|
||||
|
||||
public class CourseDriver{
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
//Create some Course objects
|
||||
Course course1 = new Course("CS1073", "Fall", 2020);
|
||||
Course course2 = new Course("CS1083", "Winter", 2021);
|
||||
Course course3 = new Course("MATH1013", "Summer", 2021);
|
||||
|
||||
|
||||
//Now I can print out my courses to confirm they
|
||||
//were created properly
|
||||
System.out.println("course1: " + course1.toString());
|
||||
System.out.println("course2: " + course2.toString());
|
||||
System.out.println("course3: " + course3.toString());
|
||||
|
||||
}
|
||||
|
||||
}
|
3
Source Code/Assignment2/info/ExampleFiles/Output.txt
Normal file
3
Source Code/Assignment2/info/ExampleFiles/Output.txt
Normal file
@ -0,0 +1,3 @@
|
||||
course1: CS1073 offered Fall 2020 Students: 0
|
||||
course2: CS1083 offered Winter 2021 Students: 0
|
||||
course3: MATH1013 offered Summer 2021 Students: 0
|
Reference in New Issue
Block a user