Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Online {
- private static String generalDomain = "MarEdu.Org";
- private int totalHours = 0;
- private int totalLessons = 0;
- private int studentsEnrolled = 0;
- private double cost;
- private String courseName;
- private String teacher;
- private String difficulty;
- private String courseDescription;
- private String[] studentNames;
- // Constructor for class
- public Online(int tH, int tL, int sE, double c, String cN, String t, String d) {
- totalHours = tH;
- totalLessons = tL;
- studentsEnrolled = sE;
- cost = c;
- courseName = cN;
- teacher = t;
- difficulty = d;
- }
- // Gets total Hours of the course
- public int getTotalHours() {
- return totalHours;
- }
- // Gets the number of students enrolled in the course
- public int getStudentsEnrolled() {
- return studentsEnrolled;
- }
- // Gets the cost of the course
- public double getCost() {
- return cost;
- }
- // Sets the cost of the course
- public void setCost(int nC) {
- cost = nC;
- }
- // Sets the amount of Students Enrolled in the course
- public void setStudentsEnrolled(int nS) {
- studentsEnrolled = nS;
- }
- // Sets the teacher of the course
- public void setTeacher(String nT) {
- teacher = nT;
- }
- // General ReadMe for any course
- public static String ReadMe() {
- return ("MarEdu's products and services are provided by MarEdu, Inc. These Terms of Use (\"Terms\") govern your use of MarEdu's website, apps, and other products and services (\"Services\"). As some of our Services may be software that is downloaded to your computer, phone, tablet, or other device, you agree that we may automatically update this software, and that these Terms will apply to such updates. Please read these Terms carefully, and contact us if you have any questions. By using our Services, you agree to be bound by these Terms, including the policies referenced in these Terms.");
- }
- // returns how many hours it takes to do a lesson
- public double HoursPerLesson() {
- return (totalHours / totalLessons);
- }
- // Returns if the course costs more than 100$
- public boolean cMTOH() {
- if (cost > 100) {
- return true;
- } else {
- return false;
- }
- }
- // Puts the course on a 50% discount
- public void discount() {
- cost = cost * 0.5;
- }
- // Empties the cost and the amount of students enrolled
- public void flushCourse() {
- studentsEnrolled = 0;
- cost = 0;
- }
- // Returns what the difficulty of the course means
- public String difficultyMeaning() {
- if (difficulty == "easy") {
- return ("This course is entry level and requires no previous experience.");
- } else if (difficulty == "medium") {
- return ("This course requires some base work and previous knowledge.");
- } else if (difficulty == "hard") {
- return ("This course is apt for experts on the field. It will require a high level of skills.");
- } else {
- return ("This course is created for the tops of their field. You will be challenged to the maximum by this course.");
- }
- }
- // Sets the description of the course
- public void setCourseDescription(String Placement) {
- courseDescription = Placement;
- }
- // Introduction String for the course
- public String courseIntro() {
- return (courseName + ":" + courseDescription);
- }
- // Sets the cost to the currency
- public void setCurrency(String currency) {
- if (currency == "Quetzales") {
- cost = cost * 7.8;
- } else if (currency == "Yen") {
- cost = cost * 110;
- } else {
- System.out.println("Sorry, we do not support that currency yet!");
- }
- }
- // Sets the studentNames to the array given in the parameter
- public void setStudentNames(String[] StudentArray) {
- for (int i = 0; i == StudentArray.length; i++) {
- studentNames[i] = StudentArray[i];
- }
- }
- // ToString Method for printing
- public String toString() {
- return (courseName + ":" + courseDescription + ". Difficulty: " + difficulty + ". TotalHours: " + totalHours + ". TotalLessons: " + totalLessons + ". Cost: " + cost + ". Teacher name: " + teacher);
- }
- public static void main(String[] args)
- {
- Online Course1 = new Online(36, 4, 200, 50, "Introduction to Machine Learning", "Mr.Yung", "easy");
- Online Course2 = new Online(67, 9, 560, 400, "Neural Networks", "Mr.Han", "medium");
- Online Course3 = new Online(300, 20, 1000, 4000, "Yale Undergraduate Degree on Artificial Intelligence", "Marcos Morales", "insane");
- System.out.println("The cost of " + Course1.courseName + " is " + Course1.getCost());
- System.out.println(Course1.courseName + " has a total of " + Course1.getStudentsEnrolled() + " students.");
- System.out.println(Course1.courseName + " will take a total of " + Course1.getTotalHours() + " hours.");
- Course2.setCost(300);
- Course2.setCourseDescription("A course based on Neural Networks and how they work");
- Course1.setCourseDescription("An introduction to the area of Machine Learning");
- Course3.setCourseDescription("A full undergraduate course to get a diploma on Artificial Intelligence");
- String[] myStr = {"Michael", "James", "Henry"};
- Course1.setStudentNames(myStr);
- Course2.setStudentsEnrolled(800);
- Course3.setCurrency("Quetzales");
- System.out.println(Course1.difficultyMeaning());
- System.out.println(Online.ReadMe());
- Course2.flushCourse();
- System.out.println("Does the course cost more than 100 dollars? " + Course1.cMTOH());
- Course1.setTeacher("Mr. Castle");
- System.out.println("Course 3 will take: " + Course3.HoursPerLesson() + " hours per lesson.");
- Course2.discount();;
- System.out.println(Course1.courseIntro());
- System.out.println(Course1);
- System.out.println(Course2);
- System.out.println(Course3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement