• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help creating mutator

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the task is

add a method signUp()which will allow a student to sign up for the race meeting. When a student signs up for the meeting, their achievements points are incremented by the attendance points of the race meeting, they are added to the team and the cost for the meeting is added to the contest's total costs. Seniors pay £10, juniors pay half of the costs, matures pay the full cost.

my meeting class is




any my student class is




anyone think they can crack it kinda stuck and dont know wher to begin

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's a mutator ?


Seriously, you'll have to tell us concretely what your problem is, not just write your assignement like that. Remember that the ranch is NotACodeMill. If there are many problems, break them into small problems.

1. Where do you add the signUp method ? What's its parameters ?
2. Increment the student's achievement points
3. Add the student to the team
4. Increase contest's total costs (value depends on the age of the student)
 
Kamran Khaen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i add the the mutator to the meeting class, im jus confused on how to do what is asked. im not asking you to rite the code for me. could you please write and example and explain the method which in contrast to what im asking.

im confused on the points 234 above

not so sure on how to do these

2. Increment the student's achievement points
3. Add the student to the team
4. Increase contest's total costs (value depends on the age of the student)
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

2. Increment the student's achievement points


There's a method called incrementPoints in the Student class.
 
Kamran Khaen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christophe Verré wrote:

2. Increment the student's achievement points


There's a method called incrementPoints in the Student class.




ok I figured out that I do a method call, but how do I add the student to the team
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Meeting class holds a team variable, which is an ArrayList of Student. If you pass the Student to the signUp method, you should be able to add the student to the team.
 
Kamran Khaen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok bessically, ive just gone back and found an error, i have to create a method to allow a student to signup for the race meeting, this is the first thing i need to do

i have another class called Society which has created an arraylist for meeting the class is posted below



do I use this array list to add the student to the race meeting
>
 
Kamran Khaen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to add a student i used this code but its giving an error
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

do I use this array list to add the student to the race meeting


Not that one. You use the ArrayList of the Meeting class. Try to think logically from here. Tell yourself "how do I add a Student to the ArrayList of the Meeting class ?" From there, you should figure out that you need a method in the Meeting class to add Students.
 
Kamran Khaen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok this is the code ive used for the signup method it worked anyone know if its correct

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks good. Maybe you'll have to check that the Student is not already in the team.
However, the totalCost is being reinitialized every time you add a Student. You'll have to fix this.
 
Kamran Khaen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christophe Verré wrote:It looks good. Maybe you'll have to check that the Student is not already in the team.
However, the totalCost is being reinitialized every time you add a Student. You'll have to fix this.



how do i fix it?, do I put this. infront of it?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. There's a isSignedUp method in the Meeting class that you can use
2. About totalCost, do you know how to add a value to another value ?
 
reply
    Bookmark Topic Watch Topic
  • New Topic