Results 1 to 11 of 11
Thread: private array
- 11-10-2009, 06:38 AM #1
Member
- Join Date
- Nov 2009
- Posts
- 6
- Rep Power
- 0
private array
(ii) The Cca class represents a Cca offered by the school. It has the following attributes:
a) ccaID (String) : an id that uniquely identifies a Cca
b) name (String) : name of the Cca (e.g. Archery)
c) numOfVacancy (int) : number of vacancies available in the Cca
d) studentList : an array of Student currently involved in the Cca
e) minEntryCgpa (double) : the minimum entry cgpa
The Cca class has the following constructor and methods:
• The constructor takes in arguments for attributes a) to e) above, and initializes all its internal attributes respectively. You may assume that there will be 100 students at most for each Cca.
• Methods for Cca class:
Name of class Cca
Name of methods getCcaID, getName, getNumOfVacancy, setNumOfVacancy, setMinEntryCgpa, getMinEntryCgpa, updateStudentList, displayStudentList, toString
• toString() method will display the values of the ccaID, name, and number of vacancies only.
• updateStudentList () method will take as input a Student and add it to the array of Student.
• displayStudentList() method will display all the students’ names in the Cca.
who can help me? and teach me how to do Pls?
- 11-10-2009, 06:49 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Start by writing the Cca class with the stated fields and methods.
P.S When I learned Java they didn't tell me what methods or properties to put in there. Just a problem description requiring a solution. You guys are blessed.
- 11-10-2009, 06:55 AM #3
Member
- Join Date
- Nov 2009
- Posts
- 6
- Rep Power
- 0
i know how to know, but i dont know how to update.....only that part i dont know.
- 11-10-2009, 07:20 AM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
The specs say "updateStudentList () method will take as input a Student and add it to the array of Student."
What have you done for it?
- 11-24-2009, 02:27 AM #5
Member
- Join Date
- Nov 2009
- Posts
- 6
- Rep Power
- 0
public class CCa {
private String ccID;
private String name;
private int numOfVacancy;
private int[] studentList;
public CCa( String ccID, String name, int numOfVacancy, int[] studentList)
{
this.ccID = ccID;
this.name = name;
this.numOfVacancy = numOfVacancy;
this.studentList = studentList;
}
public String getCcID() {
return ccID;
}
public String getName() {
return name;
}
public int getNumOfVacancy() {
return numOfVacancy;
}
public int[] getStudentList() {
return studentList;
}
public void updateStudentList(Student s) {
}
public void displayStudentList() {
for (int i = 0; i < studentList.length; i++)
{
}
System.out.println(studentList);
}
public String toString() {
String info = "\nCCID "+ccID+"\nName "+name+"\nNum Of Vacancy "+numOfVacancy+"\nStudent List "+studentList;
return info;
}
}
- 11-24-2009, 04:21 AM #6
Senior Member
- Join Date
- Nov 2009
- Posts
- 235
- Rep Power
- 4
Looks good so far. Quick question, is the array of students going to be dynamic or have a set size? If it is set, updateStudentList() should determine the next empty slot and store the paramaters there. to get the next free slot, you could run a while loop each time, or you could have a variable called studentCount. Please ask specific questions too, that way we know what answer you are expecting.
- 11-27-2009, 08:39 AM #7
Member
- Join Date
- Nov 2009
- Posts
- 3
- Rep Power
- 0
Hello tnght! My TP friend!
The answer to how to update the student list is in your Lab 5.
Please go and read up on your lab.
Oh btw, can I know your course?
- 11-29-2009, 09:11 AM #8
Member
- Join Date
- Nov 2009
- Posts
- 6
- Rep Power
- 0
Cyber and Ditial security, how about u?
- 11-29-2009, 09:33 AM #9
Member
- Join Date
- Nov 2009
- Posts
- 3
- Rep Power
- 0
Ahhhh, CDS is a nice course. The course name is nice. The course seems to teach nice stuffs. What a nice course. I love CDS.
Okay, this is going off-topic.
So I'm gonna explain how to do updateStudentList(Student stud) if not we will just be chatting.
For updateStudentList(Student stud), u nid to use a loop and a if null to find if there is a space in studentList(), then u set the studentList[i] to be the stud and you break out of the loop. Since the req didnt ask for a return, the return type is void.
Leung Zhi An from C233 asks "who are you?" <<-- I'm not him. I as dumb as he is.=X
Edit: I forgot to say what course I'm from. I'm also from CDS =DLast edited by Crapman; 11-29-2009 at 09:37 AM.
- 12-05-2009, 07:26 AM #10
Member
- Join Date
- Nov 2009
- Posts
- 6
- Rep Power
- 0
Thanks for the help. :) i from C232 class. :D
- 12-05-2009, 08:43 AM #11
Member
- Join Date
- Nov 2009
- Posts
- 6
- Rep Power
- 0
addStudentToExercise Takes in a Student object as argument and adds it to the cca exercise. (Hint: You need to update the appList)
getStudentInExercise Accepts the nric as argument and returns the corresponding Student object in the cca exercise. Otherwise return null.
displayAllStudents This method accepts no input and prints all the students’ details currently in the cca exercise.
addCca Takes in a Cca object as argument and adds it to the cca excercise.
removeCca This method accepts the ccaID of the Cca as argument and removes the Cca associated with this ccaID. It returns true if the removal is successful; otherwise returns false.
removeCca This method accepts no input. It removes those Ccas whose studentList is empty. And, it returns the total number of Ccas that it has removed from the cca excercise.
getCca Accepts the ccaId as argument and returns the Cca associated with this ccaId. Returns null if not found.
displayAllCcas This method accepts no input and prints all the ccas’ details in the cca exercise.
findMostVacancyCca This method returns the Cca object with the most vacancies.
findLeastVacancyCca This method returns the Cca object with the least vacancies.
displayAllStudentsAllCca This method will display all the students in all the ccas in the school.
displayNumberPerCca This method will display the number of students currently in each cca
processApplications This method accepts no input and it will process all the students’ applications for ccas in the cca excercise. .
A student’s application for a cca is successfully processed
( i.e. the student is assigned to the cca that he/she applies for )
if the following conditions are true:
number of vacancy of the cca is not zero
the student’s cgpa is larger than or equal to the minEntryCgpa
If a student’s application is successfully processed (i.e. the student is assigned to the cca that he/she applies for), the method will reduce the number of vacancies of that cca by 1. Then, the method must add the student to the studentList of that cca and remove the student from the appList of the cca excercise. .
How to do?
public class CcaExercise {
private String academicYear;
private String semester;
private Student[] appList;
private Cca[] ccaList;
public CcaExercise (String academicYear, String semester, Student[] appList, Cca[] ccaList)
{
this.academicYear = academicYear;
this.semester = semester;
this.appList = appList;
this.ccaList = ccaList;
}
public void addStudentToExercise(String student)
{
for(int i=0; i<appList.length; i++) {
if (appList[i]!=null) {
if (appList[i].getName().equals(name)) {
appList[i] = null;
}}}
}
public String getStudentInExercise(String nric)
{
for (int i=0; i<ccaList.length; i++){
if (student==studentList)
{
return student;
}
return null;
}
}
public void dispalyAllStudent()
{
System.out.println(student);
}
public String addCca(Cca c)
{
addCca = addCca + Cca;
}
public String removeCca(String ccaID)
{
if(ccaID==true)
{
System.out.println("remove successful");
return true;
}
else
{
System.out.println("remove not successful");
return false;
}
}
public String getCca(String ccaID)
{
if(ccaID==true)
{
}
else
{
return null;
}
}
public void diplayAllCcas()
{
System.out.println(ccaID);
}
public void displayNumberPerCca()
{
System.out.println(numberOfCcas);
}
}
Similar Threads
-
More than one input in one private method
By rice in forum New To JavaReplies: 0Last Post: 10-02-2009, 05:08 AM -
Is it acceptable to use a private object?
By saul_2110 in forum New To JavaReplies: 8Last Post: 12-08-2008, 06:04 PM -
Private Classes Clarification
By justlearning in forum New To JavaReplies: 1Last Post: 05-06-2008, 10:51 PM -
Private main method
By bugger in forum New To JavaReplies: 1Last Post: 12-21-2007, 09:45 AM -
Question of private member
By Felissa in forum Advanced JavaReplies: 2Last Post: 06-28-2007, 09:08 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks