Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.13 KB | None | 0 0
  1. public class Online {
  2. private static String generalDomain = "MarEdu.Org";
  3. private int totalHours = 0;
  4. private int totalLessons = 0;
  5. private int studentsEnrolled = 0;
  6. private double cost;
  7. private String courseName;
  8. private String teacher;
  9. private String difficulty;
  10. private String courseDescription;
  11. private String[] studentNames;
  12. // Constructor for class
  13. public Online(int tH, int tL, int sE, double c, String cN, String t, String d) {
  14. totalHours = tH;
  15. totalLessons = tL;
  16. studentsEnrolled = sE;
  17. cost = c;
  18. courseName = cN;
  19. teacher = t;
  20. difficulty = d;
  21. }
  22. // Gets total Hours of the course
  23. public int getTotalHours() {
  24. return totalHours;
  25. }
  26. // Gets the number of students enrolled in the course
  27. public int getStudentsEnrolled() {
  28. return studentsEnrolled;
  29. }
  30. // Gets the cost of the course
  31. public double getCost() {
  32. return cost;
  33. }
  34. // Sets the cost of the course
  35. public void setCost(int nC) {
  36. cost = nC;
  37. }
  38. // Sets the amount of Students Enrolled in the course
  39. public void setStudentsEnrolled(int nS) {
  40. studentsEnrolled = nS;
  41. }
  42. // Sets the teacher of the course
  43. public void setTeacher(String nT) {
  44. teacher = nT;
  45. }
  46. // General ReadMe for any course
  47. public static String ReadMe() {
  48. 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.");
  49. }
  50. // returns how many hours it takes to do a lesson
  51. public double HoursPerLesson() {
  52. return (totalHours / totalLessons);
  53. }
  54. // Returns if the course costs more than 100$
  55. public boolean cMTOH() {
  56. if (cost > 100) {
  57. return true;
  58. } else {
  59. return false;
  60. }
  61. }
  62. // Puts the course on a 50% discount
  63. public void discount() {
  64. cost = cost * 0.5;
  65. }
  66. // Empties the cost and the amount of students enrolled
  67. public void flushCourse() {
  68. studentsEnrolled = 0;
  69. cost = 0;
  70. }
  71. // Returns what the difficulty of the course means
  72. public String difficultyMeaning() {
  73. if (difficulty == "easy") {
  74. return ("This course is entry level and requires no previous experience.");
  75. } else if (difficulty == "medium") {
  76. return ("This course requires some base work and previous knowledge.");
  77. } else if (difficulty == "hard") {
  78. return ("This course is apt for experts on the field. It will require a high level of skills.");
  79. } else {
  80. return ("This course is created for the tops of their field. You will be challenged to the maximum by this course.");
  81. }
  82. }
  83. // Sets the description of the course
  84. public void setCourseDescription(String Placement) {
  85. courseDescription = Placement;
  86. }
  87. // Introduction String for the course
  88. public String courseIntro() {
  89. return (courseName + ":" + courseDescription);
  90. }
  91. // Sets the cost to the currency
  92. public void setCurrency(String currency) {
  93. if (currency == "Quetzales") {
  94. cost = cost * 7.8;
  95. } else if (currency == "Yen") {
  96. cost = cost * 110;
  97. } else {
  98. System.out.println("Sorry, we do not support that currency yet!");
  99. }
  100. }
  101. // Sets the studentNames to the array given in the parameter
  102. public void setStudentNames(String[] StudentArray) {
  103. for (int i = 0; i == StudentArray.length; i++) {
  104. studentNames[i] = StudentArray[i];
  105. }
  106. }
  107. // ToString Method for printing
  108. public String toString() {
  109. return (courseName + ":" + courseDescription + ". Difficulty: " + difficulty + ". TotalHours: " + totalHours + ". TotalLessons: " + totalLessons + ". Cost: " + cost + ". Teacher name: " + teacher);
  110. }
  111.  
  112. public static void main(String[] args)
  113. {
  114. Online Course1 = new Online(36, 4, 200, 50, "Introduction to Machine Learning", "Mr.Yung", "easy");
  115. Online Course2 = new Online(67, 9, 560, 400, "Neural Networks", "Mr.Han", "medium");
  116. Online Course3 = new Online(300, 20, 1000, 4000, "Yale Undergraduate Degree on Artificial Intelligence", "Marcos Morales", "insane");
  117. System.out.println("The cost of " + Course1.courseName + " is " + Course1.getCost());
  118. System.out.println(Course1.courseName + " has a total of " + Course1.getStudentsEnrolled() + " students.");
  119. System.out.println(Course1.courseName + " will take a total of " + Course1.getTotalHours() + " hours.");
  120. Course2.setCost(300);
  121. Course2.setCourseDescription("A course based on Neural Networks and how they work");
  122. Course1.setCourseDescription("An introduction to the area of Machine Learning");
  123. Course3.setCourseDescription("A full undergraduate course to get a diploma on Artificial Intelligence");
  124. String[] myStr = {"Michael", "James", "Henry"};
  125. Course1.setStudentNames(myStr);
  126. Course2.setStudentsEnrolled(800);
  127. Course3.setCurrency("Quetzales");
  128. System.out.println(Course1.difficultyMeaning());
  129. System.out.println(Online.ReadMe());
  130. Course2.flushCourse();
  131. System.out.println("Does the course cost more than 100 dollars? " + Course1.cMTOH());
  132. Course1.setTeacher("Mr. Castle");
  133. System.out.println("Course 3 will take: " + Course3.HoursPerLesson() + " hours per lesson.");
  134. Course2.discount();;
  135. System.out.println(Course1.courseIntro());
  136. System.out.println(Course1);
  137. System.out.println(Course2);
  138. System.out.println(Course3);
  139.  
  140. }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement