i figured out wasnt asking right questions
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
i figured out wasnt asking right questions
New problem after speaking with my teacher emerge.
/** * Write a description of class Student here. * * @author (Landon L.) * @version (a version number or a date) */ public class Student { // instance variables - replace the example below with your own private String name; private int qz1; private int qz2; private int qz3; private int qz4; private int qz5; private int [] grade; /** * Constructor for objects of class Student */ public Student(String name, int q1, int q2, int q3, int q4, int q5) { // initialise instance variables this.name = name; qz1 = q1; qz2 = q2; qz3 = q3; qz4 = q4; qz5 = q5; } //Given these rules, how would I be able to create these methods(below)??? I mean you cant use an array and only certain instance variables //are allowed. // Student will need instance variables name , qz1, qz2, qz3, qz4, and //qz5 (of types String and int, respectively). // 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. public int getQuiz(int num) { // this is what I am not sure of grade = new int[5]; return grade[num-1]; } public void setQuiz(int num, int[] gr ) { if(num < 1||num > 5) { String msg = " This quiz doesn't exist. "; throw new IllegalArgumentException(msg); } qz1 = gr[num-1]; qz2 = gr[num-1]; qz3 = gr[num-1]; qz4 = gr[num-1]; qz5 = gr[num-1]; } public void setName(String s) { name = s; } public String getName() { return name; } public String toString() { return name + " " + qz1 + " " + qz2 + " " + qz3 + " " + qz4 + " " + qz5; } }
Uhhhh, what's the question?