• 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

Need some help on some Java Homework

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Programming Exercise: Purse
Implement a class named Purse. A purse contains a collection of coins. For simplicity, we will only store the
coin names in an ArrayList<String> . In the Purse class, you should:
(1) Supply a method
public void addCoin(String coinName)
This method add one coin name to the ArrayList .
(2) Supply a method
public String toString()
This method returns a string that contains the coins in the purse in the following format
Purse[Quarter, Dime, Nickel, Dime]
(3) Supply a method
public void reverse()
This method reverses the sequence of coins in a purse.
For example, if the reverse method is called with a purse
Purse[Quarter, Dime, Nickel, Dime]
, then the purse is changed to
Purse[Dime, Nickel, Dime, Quarter]
(4) Supply a method
public void transfer(Purse other)
This method transfers the contents of one purse to another.
For example, if a is
Purse[Quarter, Dime, Nickel, Dime]
, and b is
Purse[Dime, Nickel]
,then after the call a.transer(b), a is
Purse[Quarter, Dime, Nickel, Dime, Dime, Nickel]
, and b is empty
(5) Supply a method
public boolean sameContents(Purse other)
This method checks whether the other purse has the same coins in the same order.
For example, if a is
Purse[Quarter, Dime, Nickel, Dime]
, and b is
Purse[Quarter, Dime, Nickel, Dime]
,then the call a.sameContents(b) returns true
Also, implement the PurseTester class to test the above methods of the Purse class


I'm struggling with Arrays and need help badly!
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ren Erene wrote:1. Programming Exercise: Purse
Implement a class named Purse. A purse contains a collection of coins. For simplicity, we will only store the
coin names in an ArrayList<String> . In the Purse class, you should:
(1) Supply a method
public void addCoin(String coinName)
This method add one coin name to the ArrayList .
(2) Supply a method
public String toString()
This method returns a string that contains the coins in the purse in the following format
Purse[Quarter, Dime, Nickel, Dime]
(3) Supply a method
public void reverse()
This method reverses the sequence of coins in a purse.
For example, if the reverse method is called with a purse
Purse[Quarter, Dime, Nickel, Dime]
, then the purse is changed to
Purse[Dime, Nickel, Dime, Quarter]
(4) Supply a method
public void transfer(Purse other)
This method transfers the contents of one purse to another.
For example, if a is
Purse[Quarter, Dime, Nickel, Dime]
, and b is
Purse[Dime, Nickel]
,then after the call a.transer(b), a is
Purse[Quarter, Dime, Nickel, Dime, Dime, Nickel]
, and b is empty
(5) Supply a method
public boolean sameContents(Purse other)
This method checks whether the other purse has the same coins in the same order.
For example, if a is
Purse[Quarter, Dime, Nickel, Dime]
, and b is
Purse[Quarter, Dime, Nickel, Dime]
,then the call a.sameContents(b) returns true
Also, implement the PurseTester class to test the above methods of the Purse class


Email me back at [DELETE] to communicate with me 1-1 I have a template formed for the code. I'm struggling with Arrays and need help badly!




Welcome to the ranch. Please note that JavaRanch is a learning site... as such we expect you to ShowSomeEffort. Also, since other users can learn form this, we also expect you to UseTheForumNotEmail.

So.... what have you done so far? And what issues are you running into?

Henry
 
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic