aspose file tools
The moose likes Java in General and the fly likes creting Classes problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "creting Classes problem" Watch "creting Classes problem" New topic
Author

creting Classes problem

Justin Ray
Greenhorn

Joined: Sep 10, 2009
Posts: 4
so im almost done with this assignement and i think im trying too hard or something because i just cant figure out what the program is wanting.

here it is:


my problem is at line 70 i get the output :

"TestAsst8.java:70: cannot find symbol
symbol : constructor Person()
location: class Person
public Student(double cred, double gp1){
--------------------------------------------------^
1 error".

i have tried mutiple angles at this problem for the past 4 hours and i just cant figure it out.

i also have the assignment details here:

CIS 160 - Programming Project #8

[1. Write a class called Name. It should contain the following:]
1. three String instance variables (private) for first, middle, and last names
2. three constructors for Name
a default constructor
a constructor for when first and last names are supplied
a constructor for when all three names are supplied

3. three methods that return the instance variables
one should return the first name (call it getFirst)
one should return the middle name (call it getMiddle)
one should return the last name (call it getLast)

4. three methods that set the instance variables
one should set the first name (call it setFirst)
one should set the middle name (call it setMiddle)
one should set the last name (call it setLast)

5. a method called toString that returns the whole name as a String

[2. Write a class called Person. It will use the Name class (but is not a subclass). It should contain the following:]
1. three protected instance variables
one called name that is of type Name (the class you created in problem 1)
one called gender which will be a single character (M or F)
one called id which will be a String (usually the social security number)

2. two constructors
a constructor for when only Name and gender are supplied
a constructor for when Name, gender, and id are all suplied
3. three accessor methods that return name, gender, and id (named getName, getGender, and getId)

4. one mutator method named setId that sets the id

5. a method called toString that returns all the instance variables as a String

[3. Write a derived class called Student from the base class Person.]
1. remember that this class extends Person

2. there should be two protected instance variables
a double called credits which indicates credit hours earned
a double called gpa

3. there should be one constructor which expects Name, gender, credits, and gpa

4. there should be two accessor methods which return credits and gpa respectively

5. include a method called toString that returns all the information as a String

[4. Try out your classes with the test program. Fix any minor errors that you find in the test program.]

thank you in advance
alfonz jan frithz
Greenhorn

Joined: Apr 20, 2009
Posts: 20
Lets see the Person class,



there are two constructors there, one with two arguments, another with three arguments. You want to make some class that extends Person, which is Student. Let see its constructor.



by default, when you make constructor, it calls super() first. super() is used to call your parent constructor. But, because you dont have Person constructor with no arguments, it says error.

try to change the constructor by adding

super(n, Gender); at the first line of your constructor..
Justin Ray
Greenhorn

Joined: Sep 10, 2009
Posts: 4
tyvm for your help that worked! i knew i was overthinking it and i forgot something, i allways do it.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: creting Classes problem
 
Similar Threads
getFirstName from one class (set & get) to another class (Main Program)
Order of the setter methods
JavaBean Example
Help with array List
Inheritance error?