SlideShare a Scribd company logo
1 of 5
Can I get some help creating a java method? These are the requirements for the dropStudent()
method I need to make:
method header: public boolean dropStudent(Student student)
if the student is not on the roster or waitlist, the student cannot be removed
if the student is on the roster, remove the student from the roster
since there is now one more space in the class, if the waitlist is not empty, take the first person
off the waitlist and add them to the roster
if the student is on the waitlist, remove the student from the waitlist
return true or false based on whether the student is removed or not
Main method:
public class interactiveCourseDriver { public static void main(String[] args) { Student[]
studentsInSchool = new Student[15]; studentsInSchool[0] = new Student("Adam", "Ant",
"S925", true); studentsInSchool[1] = new Student("Bob", "Barker", "S713", false);
studentsInSchool[2] = new Student("Chevy", "Chase", "S512", true); studentsInSchool[3] = new
Student("Doris", "Day", "S513", true); studentsInSchool[4] = new Student("Emilio", "Estevez",
"S516", true); studentsInSchool[5] = new Student("Farrah", "Fawcet", "S956", true);
studentsInSchool[6] = new Student("Greta", "Garbo", "S419", true); studentsInSchool[7] = new
Student("Helen", "Hunt", "S281", true); studentsInSchool[8] = new Student("Jack", "Johnson",
"S790", true); studentsInSchool[9] = new Student("Kim", "Kardashian", "S336", true);
studentsInSchool[10] = new Student("Martina", "McBride", "S156", true); studentsInSchool[11]
= new Student("Renne", "Russo", "S219", true); studentsInSchool[12] = new Student("Susan",
"Serandon", "S472", true); studentsInSchool[13] = new Student("Vince", "Vaughn", "S892",
true); studentsInSchool[14] = new Student("Walt", "Whitman", "S901", true); Course course =
new Course("Media Studies", 5, 5); System.out.println(course + "n");
System.out.println("*****TESTING DROPS"); Student studentToDrop = studentsInSchool[2];
boolean dropped = course.dropStudent(studentToDrop); System.out.println(studentToDrop +
(dropped ? " dropped successfully" : " not dropped")); System.out.println("n" + course + "n");
studentToDrop = studentsInSchool[14]; dropped = course.dropStudent(studentToDrop);
System.out.println(studentToDrop + (dropped ? " dropped successfully" : " not dropped"));
System.out.println("n" + course + "n"); studentToDrop = studentsInSchool[8]; dropped =
course.dropStudent(studentToDrop); System.out.println(studentToDrop + (dropped ? " dropped
successfully" : " not dropped")); System.out.println("n" + course + "n"); studentToDrop =
studentsInSchool[0]; dropped = course.dropStudent(studentToDrop);
System.out.println(studentToDrop + (dropped ? " dropped successfully" : " not dropped"));
System.out.println("n" + course + "n"); } }
public class Course { private String courseName; private int maxRoster = 5; private int
maxWaitlist = 5; private Student[] roster = new Student[maxRoster]; private Student[] waitlist =
new Student[maxWaitlist]; public Course(String courseName, int maxRoster, int maxWaitlist) {
this.courseName = courseName; this.maxRoster = maxRoster; this.maxWaitlist = maxWaitlist; }
public int getMaxRoster() { return maxRoster; } public int getMaxWaitlist() { return
maxWaitlist; } public void setRoster(Student[] roster, Student student, int i) { roster[i] = student;
} public void setWaitlist(Student[] waitlist, Student student, int l) { waitlist[l] = student;; } public
Student[] getRoster() { return roster; } public Student[] getWaitlist() { return waitlist; }
@Override public String toString() { // TODO Add in max waitlist length return courseName +
"n" + roster.length + " enrolled (maximum allowed " + maxRoster + ")n" + waitlist.length + "
enrolled (maximum allowed " + maxWaitlist + ")"; } public void printMenu() {
System.out.println("Please select an option."); System.out.println("1) Add a student");
System.out.println("2) Drop a student"); System.out.println("3) Print the course");
System.out.println("4) Exitn"); } public boolean addStudent(Student student) { boolean
studentAdded = false; int i = 0; int l = 0; if (student.isTuitionPaid()) { if (roster.length <
maxRoster) { studentAdded = true; setRoster(roster, student, i); Array.set(roster, i, student); i++;
} else { studentAdded = false; } if (waitlist.length < maxWaitlist && maxRoster ==
roster.length) { studentAdded = true; setWaitlist(waitlist, student, l); l++; } else { } } return
studentAdded; } } package Project2;
public class Student { private String firstName, lastName, id; private boolean tuitionPaid; public
Student(String firstName, String lastName, String id, boolean tuitionPaid) { this.firstName =
firstName; this.lastName = lastName; this.id = id; this.tuitionPaid = tuitionPaid; } public
Student(Student student) { } public String getFirstName() { return firstName; } public String
getLastName() { return lastName; } public void setFirstName(String firstName) { this.firstName
= firstName; } public void setLastName(String lastName) { this.lastName = lastName; } public
String getID() { return id; } public void setID(String id) { this.id = id; } public boolean
isTuitionPaid() { return tuitionPaid; } public void setTuitionPaid(boolean tuitionPaid) {
this.tuitionPaid = tuitionPaid; } @Override public boolean equals(Object obj) { if(obj != null) {
Student student = (Student)obj; return id.equals(student.id) &&
firstName.equalsIgnoreCase(student.firstName) && lastName.equalsIgnoreCase(lastName) &&
tuitionPaid == student.tuitionPaid; } return false; // obj is null or not an object of Student class }
@Override public String toString() { return firstName + " " + lastName + " (" + id + ")"; } }
Below is the needed output for the test:
Media Studies
0 enrolled (maximum allowed 5)
0 on waitlist (maximum allowed 5)
*****TESTING ADDS
Adam Ant (S925) added successfully
Bob Barker (S713) not added
Chevy Chase (S512) added successfully
Doris Day (S513) added successfully
Emilio Estevez (S516) added successfully
Farrah Fawcet (S956) added successfully
Greta Garbo (S419) added successfully
Helen Hunt (S281) added successfully
Jack Johnson (S790) added successfully
Kim Kardashian (S336) added successfully
Martina McBride (S156) added successfully
Renne Russo (S219) not added
Susan Serandon (S472) not added
Vince Vaughn (S892) not added
Walt Whitman (S901) not added
Media Studies
5 enrolled (maximum allowed 5)
Adam Ant (S925)
Chevy Chase (S512)
Doris Day (S513)
Emilio Estevez (S516)
Farrah Fawcet (S956)
5 on waitlist (maximum allowed 5)
Greta Garbo (S419)
Helen Hunt (S281)
Jack Johnson (S790)
Kim Kardashian (S336)
Martina McBride (S156)
Chevy Chase (S512) not added
Media Studies
5 enrolled (maximum allowed 5)
Adam Ant (S925)
Chevy Chase (S512)
Doris Day (S513)
Emilio Estevez (S516)
Farrah Fawcet (S956)
5 on waitlist (maximum allowed 5)
Greta Garbo (S419)
Helen Hunt (S281)
Jack Johnson (S790)
Kim Kardashian (S336)
Martina McBride (S156)
Helen Hunt (S281) not added
Media Studies
5 enrolled (maximum allowed 5)
Adam Ant (S925)
Chevy Chase (S512)
Doris Day (S513)
Emilio Estevez (S516)
Farrah Fawcet (S956)
5 on waitlist (maximum allowed 5)
Greta Garbo (S419)
Helen Hunt (S281)
Jack Johnson (S790)
Kim Kardashian (S336)
Martina McBride (S156)
*****TESTING DROPS
Chevy Chase (S512) dropped successfully
Media Studies
5 enrolled (maximum allowed 5)
Adam Ant (S925)
Doris Day (S513)
Emilio Estevez (S516)
Farrah Fawcet (S956)
Greta Garbo (S419)
4 on waitlist (maximum allowed 5)
Helen Hunt (S281)
Jack Johnson (S790)
Kim Kardashian (S336)
Martina McBride (S156)
Walt Whitman (S901) not dropped
Media Studies
5 enrolled (maximum allowed 5)
Adam Ant (S925)
Doris Day (S513)
Emilio Estevez (S516)
Farrah Fawcet (S956)
Greta Garbo (S419)
4 on waitlist (maximum allowed 5)
Helen Hunt (S281)
Jack Johnson (S790)
Kim Kardashian (S336)
Martina McBride (S156)
Jack Johnson (S790) dropped successfully
Media Studies
5 enrolled (maximum allowed 5)
Adam Ant (S925)
Doris Day (S513)
Emilio Estevez (S516)
Farrah Fawcet (S956)
Greta Garbo (S419)
3 on waitlist (maximum allowed 5)
Helen Hunt (S281)
Kim Kardashian (S336)
Martina McBride (S156)
Adam Ant (S925) dropped successfully
Media Studies
5 enrolled (maximum allowed 5)
Doris Day (S513)
Emilio Estevez (S516)
Farrah Fawcet (S956)
Greta Garbo (S419)
Helen Hunt (S281)
2 on waitlist (maximum allowed 5)
Kim Kardashian (S336)
Martina McBride (S156)

More Related Content

Similar to Can I get some help creating a java method- These are the requirements.docx

About java
About javaAbout java
About javaJay Xu
 
Scala - fra newbie til ninja på en time
Scala - fra newbie til ninja på en timeScala - fra newbie til ninja på en time
Scala - fra newbie til ninja på en timekarianneberg
 
Professional-grade software design
Professional-grade software designProfessional-grade software design
Professional-grade software designBrian Fenton
 
My code is not matching up with the results.The output for the cod.pdf
My code is not matching up with the results.The output for the cod.pdfMy code is not matching up with the results.The output for the cod.pdf
My code is not matching up with the results.The output for the cod.pdfsolimankellymattwe60
 
RuleML2015 : Hybrid Relational and Graph Reasoning
RuleML2015 : Hybrid Relational and Graph Reasoning RuleML2015 : Hybrid Relational and Graph Reasoning
RuleML2015 : Hybrid Relational and Graph Reasoning Mark Proctor
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdfaplolomedicalstoremr
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfShashikantSathe3
 
Chapter 8 Polymorphism
Chapter 8 PolymorphismChapter 8 Polymorphism
Chapter 8 PolymorphismOUM SAOKOSAL
 
05-OOP-Abstract Classes____________.pptx
05-OOP-Abstract Classes____________.pptx05-OOP-Abstract Classes____________.pptx
05-OOP-Abstract Classes____________.pptxpaautomation11
 
Hey Kotlin, How it works?
Hey Kotlin, How it works?Hey Kotlin, How it works?
Hey Kotlin, How it works?Chang W. Doh
 
Methods Of Thread Class
Methods Of Thread ClassMethods Of Thread Class
Methods Of Thread Classkqibtiya5
 
Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Chang W. Doh
 
Refactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteRefactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteMariano Sánchez
 

Similar to Can I get some help creating a java method- These are the requirements.docx (20)

Java Class Design
Java Class DesignJava Class Design
Java Class Design
 
Java generics
Java genericsJava generics
Java generics
 
About java
About javaAbout java
About java
 
Scala - fra newbie til ninja på en time
Scala - fra newbie til ninja på en timeScala - fra newbie til ninja på en time
Scala - fra newbie til ninja på en time
 
Professional-grade software design
Professional-grade software designProfessional-grade software design
Professional-grade software design
 
My code is not matching up with the results.The output for the cod.pdf
My code is not matching up with the results.The output for the cod.pdfMy code is not matching up with the results.The output for the cod.pdf
My code is not matching up with the results.The output for the cod.pdf
 
RuleML2015 : Hybrid Relational and Graph Reasoning
RuleML2015 : Hybrid Relational and Graph Reasoning RuleML2015 : Hybrid Relational and Graph Reasoning
RuleML2015 : Hybrid Relational and Graph Reasoning
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
 
Chapter 8 Polymorphism
Chapter 8 PolymorphismChapter 8 Polymorphism
Chapter 8 Polymorphism
 
05-OOP-Abstract Classes____________.pptx
05-OOP-Abstract Classes____________.pptx05-OOP-Abstract Classes____________.pptx
05-OOP-Abstract Classes____________.pptx
 
Jeop game-final-review
Jeop game-final-reviewJeop game-final-review
Jeop game-final-review
 
Hey Kotlin, How it works?
Hey Kotlin, How it works?Hey Kotlin, How it works?
Hey Kotlin, How it works?
 
Java 8 revealed
Java 8 revealedJava 8 revealed
Java 8 revealed
 
Methods Of Thread Class
Methods Of Thread ClassMethods Of Thread Class
Methods Of Thread Class
 
Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요Kotlin, 어떻게 동작하나요
Kotlin, 어떻게 동작하나요
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 
Refactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteRefactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existente
 
Java Methods
Java MethodsJava Methods
Java Methods
 

More from CharlesCSZWhitei

Canada has a National Health Plan- which means there is one health pla.docx
Canada has a National Health Plan- which means there is one health pla.docxCanada has a National Health Plan- which means there is one health pla.docx
Canada has a National Health Plan- which means there is one health pla.docxCharlesCSZWhitei
 
Can you please guide me in details- Let U Uniform (0-1)- Find a-b such.docx
Can you please guide me in details- Let U Uniform (0-1)- Find a-b such.docxCan you please guide me in details- Let U Uniform (0-1)- Find a-b such.docx
Can you please guide me in details- Let U Uniform (0-1)- Find a-b such.docxCharlesCSZWhitei
 
Can you help me in to flat this without recursion i-e simple loops- d.docx
Can you help me in to flat this without recursion i-e simple loops-  d.docxCan you help me in to flat this without recursion i-e simple loops-  d.docx
Can you help me in to flat this without recursion i-e simple loops- d.docxCharlesCSZWhitei
 
Can you explain if there would be any variations in the correlation be.docx
Can you explain if there would be any variations in the correlation be.docxCan you explain if there would be any variations in the correlation be.docx
Can you explain if there would be any variations in the correlation be.docxCharlesCSZWhitei
 
Can you draw it so it's easy to understand- Minimize the following DFA.docx
Can you draw it so it's easy to understand- Minimize the following DFA.docxCan you draw it so it's easy to understand- Minimize the following DFA.docx
Can you draw it so it's easy to understand- Minimize the following DFA.docxCharlesCSZWhitei
 
Can you answer the substeps 1 through 8 Study the following image and.docx
Can you answer the substeps 1 through 8 Study the following image and.docxCan you answer the substeps 1 through 8 Study the following image and.docx
Can you answer the substeps 1 through 8 Study the following image and.docxCharlesCSZWhitei
 
can someone write out the steps- Clonex Labs- Incorporated- uses the.docx
can someone write out the steps-  Clonex Labs- Incorporated- uses the.docxcan someone write out the steps-  Clonex Labs- Incorporated- uses the.docx
can someone write out the steps- Clonex Labs- Incorporated- uses the.docxCharlesCSZWhitei
 
can someone please create the pictorial desigj Team Assignment Susans.docx
can someone please create the pictorial desigj  Team Assignment Susans.docxcan someone please create the pictorial desigj  Team Assignment Susans.docx
can someone please create the pictorial desigj Team Assignment Susans.docxCharlesCSZWhitei
 
Can someone help with this- Attached is all the information- Thank you.docx
Can someone help with this- Attached is all the information- Thank you.docxCan someone help with this- Attached is all the information- Thank you.docx
Can someone help with this- Attached is all the information- Thank you.docxCharlesCSZWhitei
 
c) OB is for evervone- Build an argument to support this statement-.docx
c) OB is for evervone- Build an argument to support this statement-.docxc) OB is for evervone- Build an argument to support this statement-.docx
c) OB is for evervone- Build an argument to support this statement-.docxCharlesCSZWhitei
 
c++ please as fast as u can 1-The term mutator in the C++ Object Orien.docx
c++ please as fast as u can 1-The term mutator in the C++ Object Orien.docxc++ please as fast as u can 1-The term mutator in the C++ Object Orien.docx
c++ please as fast as u can 1-The term mutator in the C++ Object Orien.docxCharlesCSZWhitei
 
c++ 1-The term mutator in the C++ Object Oriented Programming commonly.docx
c++ 1-The term mutator in the C++ Object Oriented Programming commonly.docxc++ 1-The term mutator in the C++ Object Oriented Programming commonly.docx
c++ 1-The term mutator in the C++ Object Oriented Programming commonly.docxCharlesCSZWhitei
 
By joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docx
By joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docxBy joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docx
By joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docxCharlesCSZWhitei
 
caldelsta the rebobiety of the folbowing x x x.docx
caldelsta the rebobiety of the folbowing x x x.docxcaldelsta the rebobiety of the folbowing x x x.docx
caldelsta the rebobiety of the folbowing x x x.docxCharlesCSZWhitei
 
Calculate the payout ratio- earnings per share- and return on common s.docx
Calculate the payout ratio- earnings per share- and return on common s.docxCalculate the payout ratio- earnings per share- and return on common s.docx
Calculate the payout ratio- earnings per share- and return on common s.docxCharlesCSZWhitei
 
Calculate the genotypes and genotypic proportions of a cross between A.docx
Calculate the genotypes and genotypic proportions of a cross between A.docxCalculate the genotypes and genotypic proportions of a cross between A.docx
Calculate the genotypes and genotypic proportions of a cross between A.docxCharlesCSZWhitei
 
Business Philosophy- What is important to you in business- How will y.docx
Business Philosophy- What is important to you in business-  How will y.docxBusiness Philosophy- What is important to you in business-  How will y.docx
Business Philosophy- What is important to you in business- How will y.docxCharlesCSZWhitei
 
Calculate the CFFA- Balance Sheet $150-000 20142015 20142015Cas.docx
Calculate the CFFA-     Balance Sheet $150-000    20142015 20142015Cas.docxCalculate the CFFA-     Balance Sheet $150-000    20142015 20142015Cas.docx
Calculate the CFFA- Balance Sheet $150-000 20142015 20142015Cas.docxCharlesCSZWhitei
 
Cabell Products is a division of a major corporation- Last year the di.docx
Cabell Products is a division of a major corporation- Last year the di.docxCabell Products is a division of a major corporation- Last year the di.docx
Cabell Products is a division of a major corporation- Last year the di.docxCharlesCSZWhitei
 
Business Ethics and White-Collar Crime Business Ethics There are many (2).docx
Business Ethics and White-Collar Crime Business Ethics There are many (2).docxBusiness Ethics and White-Collar Crime Business Ethics There are many (2).docx
Business Ethics and White-Collar Crime Business Ethics There are many (2).docxCharlesCSZWhitei
 

More from CharlesCSZWhitei (20)

Canada has a National Health Plan- which means there is one health pla.docx
Canada has a National Health Plan- which means there is one health pla.docxCanada has a National Health Plan- which means there is one health pla.docx
Canada has a National Health Plan- which means there is one health pla.docx
 
Can you please guide me in details- Let U Uniform (0-1)- Find a-b such.docx
Can you please guide me in details- Let U Uniform (0-1)- Find a-b such.docxCan you please guide me in details- Let U Uniform (0-1)- Find a-b such.docx
Can you please guide me in details- Let U Uniform (0-1)- Find a-b such.docx
 
Can you help me in to flat this without recursion i-e simple loops- d.docx
Can you help me in to flat this without recursion i-e simple loops-  d.docxCan you help me in to flat this without recursion i-e simple loops-  d.docx
Can you help me in to flat this without recursion i-e simple loops- d.docx
 
Can you explain if there would be any variations in the correlation be.docx
Can you explain if there would be any variations in the correlation be.docxCan you explain if there would be any variations in the correlation be.docx
Can you explain if there would be any variations in the correlation be.docx
 
Can you draw it so it's easy to understand- Minimize the following DFA.docx
Can you draw it so it's easy to understand- Minimize the following DFA.docxCan you draw it so it's easy to understand- Minimize the following DFA.docx
Can you draw it so it's easy to understand- Minimize the following DFA.docx
 
Can you answer the substeps 1 through 8 Study the following image and.docx
Can you answer the substeps 1 through 8 Study the following image and.docxCan you answer the substeps 1 through 8 Study the following image and.docx
Can you answer the substeps 1 through 8 Study the following image and.docx
 
can someone write out the steps- Clonex Labs- Incorporated- uses the.docx
can someone write out the steps-  Clonex Labs- Incorporated- uses the.docxcan someone write out the steps-  Clonex Labs- Incorporated- uses the.docx
can someone write out the steps- Clonex Labs- Incorporated- uses the.docx
 
can someone please create the pictorial desigj Team Assignment Susans.docx
can someone please create the pictorial desigj  Team Assignment Susans.docxcan someone please create the pictorial desigj  Team Assignment Susans.docx
can someone please create the pictorial desigj Team Assignment Susans.docx
 
Can someone help with this- Attached is all the information- Thank you.docx
Can someone help with this- Attached is all the information- Thank you.docxCan someone help with this- Attached is all the information- Thank you.docx
Can someone help with this- Attached is all the information- Thank you.docx
 
c) OB is for evervone- Build an argument to support this statement-.docx
c) OB is for evervone- Build an argument to support this statement-.docxc) OB is for evervone- Build an argument to support this statement-.docx
c) OB is for evervone- Build an argument to support this statement-.docx
 
c++ please as fast as u can 1-The term mutator in the C++ Object Orien.docx
c++ please as fast as u can 1-The term mutator in the C++ Object Orien.docxc++ please as fast as u can 1-The term mutator in the C++ Object Orien.docx
c++ please as fast as u can 1-The term mutator in the C++ Object Orien.docx
 
c++ 1-The term mutator in the C++ Object Oriented Programming commonly.docx
c++ 1-The term mutator in the C++ Object Oriented Programming commonly.docxc++ 1-The term mutator in the C++ Object Oriented Programming commonly.docx
c++ 1-The term mutator in the C++ Object Oriented Programming commonly.docx
 
By joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docx
By joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docxBy joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docx
By joining these two tables using a COURSE RIGHT OUTER JOIN DEPARTMENT.docx
 
caldelsta the rebobiety of the folbowing x x x.docx
caldelsta the rebobiety of the folbowing x x x.docxcaldelsta the rebobiety of the folbowing x x x.docx
caldelsta the rebobiety of the folbowing x x x.docx
 
Calculate the payout ratio- earnings per share- and return on common s.docx
Calculate the payout ratio- earnings per share- and return on common s.docxCalculate the payout ratio- earnings per share- and return on common s.docx
Calculate the payout ratio- earnings per share- and return on common s.docx
 
Calculate the genotypes and genotypic proportions of a cross between A.docx
Calculate the genotypes and genotypic proportions of a cross between A.docxCalculate the genotypes and genotypic proportions of a cross between A.docx
Calculate the genotypes and genotypic proportions of a cross between A.docx
 
Business Philosophy- What is important to you in business- How will y.docx
Business Philosophy- What is important to you in business-  How will y.docxBusiness Philosophy- What is important to you in business-  How will y.docx
Business Philosophy- What is important to you in business- How will y.docx
 
Calculate the CFFA- Balance Sheet $150-000 20142015 20142015Cas.docx
Calculate the CFFA-     Balance Sheet $150-000    20142015 20142015Cas.docxCalculate the CFFA-     Balance Sheet $150-000    20142015 20142015Cas.docx
Calculate the CFFA- Balance Sheet $150-000 20142015 20142015Cas.docx
 
Cabell Products is a division of a major corporation- Last year the di.docx
Cabell Products is a division of a major corporation- Last year the di.docxCabell Products is a division of a major corporation- Last year the di.docx
Cabell Products is a division of a major corporation- Last year the di.docx
 
Business Ethics and White-Collar Crime Business Ethics There are many (2).docx
Business Ethics and White-Collar Crime Business Ethics There are many (2).docxBusiness Ethics and White-Collar Crime Business Ethics There are many (2).docx
Business Ethics and White-Collar Crime Business Ethics There are many (2).docx
 

Recently uploaded

MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 

Recently uploaded (20)

MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 

Can I get some help creating a java method- These are the requirements.docx

  • 1. Can I get some help creating a java method? These are the requirements for the dropStudent() method I need to make: method header: public boolean dropStudent(Student student) if the student is not on the roster or waitlist, the student cannot be removed if the student is on the roster, remove the student from the roster since there is now one more space in the class, if the waitlist is not empty, take the first person off the waitlist and add them to the roster if the student is on the waitlist, remove the student from the waitlist return true or false based on whether the student is removed or not Main method: public class interactiveCourseDriver { public static void main(String[] args) { Student[] studentsInSchool = new Student[15]; studentsInSchool[0] = new Student("Adam", "Ant", "S925", true); studentsInSchool[1] = new Student("Bob", "Barker", "S713", false); studentsInSchool[2] = new Student("Chevy", "Chase", "S512", true); studentsInSchool[3] = new Student("Doris", "Day", "S513", true); studentsInSchool[4] = new Student("Emilio", "Estevez", "S516", true); studentsInSchool[5] = new Student("Farrah", "Fawcet", "S956", true); studentsInSchool[6] = new Student("Greta", "Garbo", "S419", true); studentsInSchool[7] = new Student("Helen", "Hunt", "S281", true); studentsInSchool[8] = new Student("Jack", "Johnson", "S790", true); studentsInSchool[9] = new Student("Kim", "Kardashian", "S336", true); studentsInSchool[10] = new Student("Martina", "McBride", "S156", true); studentsInSchool[11] = new Student("Renne", "Russo", "S219", true); studentsInSchool[12] = new Student("Susan", "Serandon", "S472", true); studentsInSchool[13] = new Student("Vince", "Vaughn", "S892", true); studentsInSchool[14] = new Student("Walt", "Whitman", "S901", true); Course course = new Course("Media Studies", 5, 5); System.out.println(course + "n"); System.out.println("*****TESTING DROPS"); Student studentToDrop = studentsInSchool[2]; boolean dropped = course.dropStudent(studentToDrop); System.out.println(studentToDrop + (dropped ? " dropped successfully" : " not dropped")); System.out.println("n" + course + "n"); studentToDrop = studentsInSchool[14]; dropped = course.dropStudent(studentToDrop); System.out.println(studentToDrop + (dropped ? " dropped successfully" : " not dropped")); System.out.println("n" + course + "n"); studentToDrop = studentsInSchool[8]; dropped = course.dropStudent(studentToDrop); System.out.println(studentToDrop + (dropped ? " dropped successfully" : " not dropped")); System.out.println("n" + course + "n"); studentToDrop = studentsInSchool[0]; dropped = course.dropStudent(studentToDrop); System.out.println(studentToDrop + (dropped ? " dropped successfully" : " not dropped")); System.out.println("n" + course + "n"); } } public class Course { private String courseName; private int maxRoster = 5; private int maxWaitlist = 5; private Student[] roster = new Student[maxRoster]; private Student[] waitlist =
  • 2. new Student[maxWaitlist]; public Course(String courseName, int maxRoster, int maxWaitlist) { this.courseName = courseName; this.maxRoster = maxRoster; this.maxWaitlist = maxWaitlist; } public int getMaxRoster() { return maxRoster; } public int getMaxWaitlist() { return maxWaitlist; } public void setRoster(Student[] roster, Student student, int i) { roster[i] = student; } public void setWaitlist(Student[] waitlist, Student student, int l) { waitlist[l] = student;; } public Student[] getRoster() { return roster; } public Student[] getWaitlist() { return waitlist; } @Override public String toString() { // TODO Add in max waitlist length return courseName + "n" + roster.length + " enrolled (maximum allowed " + maxRoster + ")n" + waitlist.length + " enrolled (maximum allowed " + maxWaitlist + ")"; } public void printMenu() { System.out.println("Please select an option."); System.out.println("1) Add a student"); System.out.println("2) Drop a student"); System.out.println("3) Print the course"); System.out.println("4) Exitn"); } public boolean addStudent(Student student) { boolean studentAdded = false; int i = 0; int l = 0; if (student.isTuitionPaid()) { if (roster.length < maxRoster) { studentAdded = true; setRoster(roster, student, i); Array.set(roster, i, student); i++; } else { studentAdded = false; } if (waitlist.length < maxWaitlist && maxRoster == roster.length) { studentAdded = true; setWaitlist(waitlist, student, l); l++; } else { } } return studentAdded; } } package Project2; public class Student { private String firstName, lastName, id; private boolean tuitionPaid; public Student(String firstName, String lastName, String id, boolean tuitionPaid) { this.firstName = firstName; this.lastName = lastName; this.id = id; this.tuitionPaid = tuitionPaid; } public Student(Student student) { } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public void setFirstName(String firstName) { this.firstName = firstName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getID() { return id; } public void setID(String id) { this.id = id; } public boolean isTuitionPaid() { return tuitionPaid; } public void setTuitionPaid(boolean tuitionPaid) { this.tuitionPaid = tuitionPaid; } @Override public boolean equals(Object obj) { if(obj != null) { Student student = (Student)obj; return id.equals(student.id) && firstName.equalsIgnoreCase(student.firstName) && lastName.equalsIgnoreCase(lastName) && tuitionPaid == student.tuitionPaid; } return false; // obj is null or not an object of Student class } @Override public String toString() { return firstName + " " + lastName + " (" + id + ")"; } } Below is the needed output for the test: Media Studies 0 enrolled (maximum allowed 5) 0 on waitlist (maximum allowed 5) *****TESTING ADDS Adam Ant (S925) added successfully Bob Barker (S713) not added Chevy Chase (S512) added successfully Doris Day (S513) added successfully Emilio Estevez (S516) added successfully Farrah Fawcet (S956) added successfully Greta Garbo (S419) added successfully
  • 3. Helen Hunt (S281) added successfully Jack Johnson (S790) added successfully Kim Kardashian (S336) added successfully Martina McBride (S156) added successfully Renne Russo (S219) not added Susan Serandon (S472) not added Vince Vaughn (S892) not added Walt Whitman (S901) not added Media Studies 5 enrolled (maximum allowed 5) Adam Ant (S925) Chevy Chase (S512) Doris Day (S513) Emilio Estevez (S516) Farrah Fawcet (S956) 5 on waitlist (maximum allowed 5) Greta Garbo (S419) Helen Hunt (S281) Jack Johnson (S790) Kim Kardashian (S336) Martina McBride (S156) Chevy Chase (S512) not added Media Studies 5 enrolled (maximum allowed 5) Adam Ant (S925) Chevy Chase (S512) Doris Day (S513) Emilio Estevez (S516) Farrah Fawcet (S956) 5 on waitlist (maximum allowed 5) Greta Garbo (S419) Helen Hunt (S281) Jack Johnson (S790) Kim Kardashian (S336) Martina McBride (S156) Helen Hunt (S281) not added Media Studies 5 enrolled (maximum allowed 5) Adam Ant (S925) Chevy Chase (S512) Doris Day (S513)
  • 4. Emilio Estevez (S516) Farrah Fawcet (S956) 5 on waitlist (maximum allowed 5) Greta Garbo (S419) Helen Hunt (S281) Jack Johnson (S790) Kim Kardashian (S336) Martina McBride (S156) *****TESTING DROPS Chevy Chase (S512) dropped successfully Media Studies 5 enrolled (maximum allowed 5) Adam Ant (S925) Doris Day (S513) Emilio Estevez (S516) Farrah Fawcet (S956) Greta Garbo (S419) 4 on waitlist (maximum allowed 5) Helen Hunt (S281) Jack Johnson (S790) Kim Kardashian (S336) Martina McBride (S156) Walt Whitman (S901) not dropped Media Studies 5 enrolled (maximum allowed 5) Adam Ant (S925) Doris Day (S513) Emilio Estevez (S516) Farrah Fawcet (S956) Greta Garbo (S419) 4 on waitlist (maximum allowed 5) Helen Hunt (S281) Jack Johnson (S790) Kim Kardashian (S336) Martina McBride (S156) Jack Johnson (S790) dropped successfully Media Studies 5 enrolled (maximum allowed 5) Adam Ant (S925) Doris Day (S513)
  • 5. Emilio Estevez (S516) Farrah Fawcet (S956) Greta Garbo (S419) 3 on waitlist (maximum allowed 5) Helen Hunt (S281) Kim Kardashian (S336) Martina McBride (S156) Adam Ant (S925) dropped successfully Media Studies 5 enrolled (maximum allowed 5) Doris Day (S513) Emilio Estevez (S516) Farrah Fawcet (S956) Greta Garbo (S419) Helen Hunt (S281) 2 on waitlist (maximum allowed 5) Kim Kardashian (S336) Martina McBride (S156)