i know this isnt really alot of code, but i wanted to make sure i was getting off on the right foot before i got too deep and wasted alot of time. if anyone has feedback, tips, or advice i would love to hear them. thanks to anyone who can help.
----------------------- Page 1-----------------------
16.05 Assignment Instructions
Instructions: For this assignment, you are going to use all your standard algorithm methods.
1. Create a folder called 16.05 Assignment in your module 16 assignments folder.
2. Create an abstract class called Student.
a. Student will need instance variables name , qz1, qz2, qz3, qz4, and
qz5 (of types String and int, respectively).
b. Student will need appropriate methods and constructors. To make things
interesting, create a getQuiz() method that takes in a quiz number as input and
then returns the appropriate quiz value. Likewise, setQuiz() will take as input
a quiz number and quiz score, and then put the value into the right variable. Make
sure to have a toString() method that prints the name of the student along
with the quiz scores.
c. Save the class as Student.java.
3. You are to create a class called TestStudent and save it as TestStudent.java.
a. Make sure that you create an array called myClass. Add the following students
with their quiz scores.
Candidate Q1 Q2 Q3 Q4 Q5
Mark Kennedy 70 80 90 100 90
Max Gerard 80 85 90 85 80
Jean Smith 50 79 89 99 100
Betty Farm 85 80 85 88 89
Dilbert Gamma 70 70 90 70 80
b. Create a method called printBook() that traverses through the array and prints
out each element.
c. Create a method called replaceName() that replaces a student’s name with a
d. Create a method called replaceQuiz() that replaces a student’s quiz grade
with a new one. It should replace only one quiz grade, as indicated, when it is
called. It will have the array, quiz number, and quiz value as input.
e. Create a method called replaceStudent() that replaces a student with
another one. It will have the array, name to replace, new student name, and quiz
scores as input.
f. Create a method called insertStudent() that inserts a new student before
another student in the array. It will have the array, name to find, new student
name, and quiz scores as input.
g. Create a method called deleteStudent() that finds a student by name and
then deletes that student.
h. Remember to make sure your methods handle there being null elements in the
i. Test your methods. The output should be similar to that shown below:
----------------------- Page 2-----------------------
----------------------- Page 3-----------------------
4. Now create a class TestStudent2 and save it as TestStudent2.java.
a. Create the same items as for TestStudent; however, use an ArrayList instead.
b. Output will look similar to that shown below.
----------------------- Page 4-----------------------
----------------------- Page 5-----------------------
I have a couple of hints for you. Your assignment says you will need instance variables q1, q2, q3, q4, and q5. You only have one integer instance variable called quiz. Your toString() method tries to compensate for this by using all those variables as parameters, but that's not what you want. You want a toString() method that takes no parameters and just works with instance variables. Finally, q1 + q2 + etc. isn't doing concatenation (putting two strings together); it's adding up all the integers into a total ... also not what you want.
Take another stab at it and post it here. Good luck!
im still really struggling. some tips as of what direction to go in would be a life saver. i have been waiting diligently for replies. appreciation goes out to anyone who can help.
At this point you will have to resort to desperate measures, using very high-tech equipment: paper, pencil and eraser. Preferably a big eraser; you will use it a lot
nathan gibson wrote:i have been trying to think my way through the parts i dont understand. . . .
Write down exactly what you think your program should do, but leave large gaps between your stages. Then divide each stage and subdivide it until you have really tiny steps. Find a copy of Code Complete by Steve McConnell and have a look at the chapter about the pseudocode process. That is what you are doing here. You want to get the whole thing down to words of one syllable which anybody can understand. Then turn it into code. You might end up throwing away most of what you have done before, but you will have something which works.
from here i have fixed my array and my instance variables. now precisely what im trying to accomplish is:
The setQuiz method needs to accept a quiz number and the score for that quiz.
getQuiz accepts a quiz number and returns the score for that applicable quiz.
the reason im having trouble with this is that i have 5 quizzes for 5 different students. im not sure how to write the method that it returns the way im trying to get it to. thanks if anyone can help me get this sorted out.
my only problem is the last line in my insert student method. "list[location] = new student(addN, addS);" where student is giving the error cannot find symbol consructor student. so far that is my only error in this class, but i cannot find the problem.
my last leg to complete is to finish the two methods i have been having trouble with all along. at this point im begging for some insight. i have been looking at examples, but i cant fins any that fit my specific situation. im going to keep looking. if anyone can help me out with this, thanks.