Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Practice exercise 4  RSS feed

 
pierre val
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


write only the main() method using the exact steps.
- create a ref called al of the given class
- create an object for that ref
- send the setup() message passing "mike" and reading in 100 for the scan
- deposit 20.50 into his account
- withdraw 3 from his account
- print his new balance without saving the received value in a variable

Using the same class above on the right hand side, correct any errors without changing the method name.
A. double d = a1.deposit("Sarah");
b. string s = a1.who ("Sarah");
c. double d = a1.withdraw(10);
d. a1.setUp(200);
e. a1.withdraw(10,"sarah");


I need help with this practice exercise, where should i start to create the reference called a1 and create an obj for that ref...thank you !
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pierre val wrote:I need help with this practice exercise, where should i start to create the reference called a1 and create an obj for that ref...thank you !

Well, you know how to create an object don't you? I doubt they would have given you this exercise if they haven't explained that to you.

And the instructions tell you that you're writing the main() method. So my suggestion: Try a few things out for yourself, and come back and show us your main() method if you have problems.

HIH

Winston

PS: And welcome to JavaRanch!
 
pierre val
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i found solution to 1 and 2
Account a1; ---> reference
a1 = new Account(); ---> object

im still confuse about the 3rd part of question no 1
 
Carey Brown
Bartender
Posts: 2982
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find this wording to be a bit obtuse
send the setup() message passing "mike" and reading in 100 for the scan

I would have said
call the setup() method passing "mike" and entering in 100 for the scan
 
pierre val
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya this is my homework and that is what the professor wrote in the assignment. i'm kinda confuse about it too, but maybe he wants us to change something in the setUp method but im not so sure

 
Carey Brown
Bartender
Posts: 2982
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pierre val wrote:ya this is my homework and that is what the professor wrote in the assignment. i'm kinda confuse about it too, but maybe he wants us to change something in the setUp method but im not so sure


call the setup() method passing "mike" and entering in 100 for the scan

Nothing here implies changing setup().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!