• Post Reply Bookmark Topic Watch Topic
  • New Topic

A coin project in the making  RSS feed

 
Kyle Grady
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is happening is that this is a program is that that there are coins being made.
It does not have client involvement so this is all interface but here comes the kicker, i having to make an interface become involved with a hierarchy and it's sub-methods.

Write a class named Coin. Coins have a year, a face value, a weight, and a state of heads or tails.

A coin can be flipped and a coin can be sold for more than its face value if it is made of precious metal or is rare. Precious metal coins are valued by their weight and the current price of their metal on the world market. Rare coins are categorized by age:

Extremely rare coins are over 1500 years old and sell for their face value plus $1500
Moderately rare coins are between 1500 and 1000 years old and sell for their face value plus $1000
Recently rare coins are between 1000 and 500 years old and sell for their face value plus $500
Maybe rare coins are between 500 and 200 years old and sell for their face value plus $200
All coins less than 200 years old are not rare coins and are not sold. Only precious metal and rare coins can be sold.


Create a class hierarchy with a Coin class, a preciousCoin class, and a rareCoin class. Create a flippable interface so that all the coin objects can be flipped. Create a metal class. Determine the necessary instance variables and methods for the metal class. For this exercise just assume gold and silver as the precious metals involved. Rare coins can also be precious metal coins, in which case, they would sell for their rare calculated value plus the value of the weight of their metal.

Write a test client program to construct coins, flip coins, and sell coins if applicable. Develop sufficient test data to test all cases of all classes and the interface thoroughly. Your test client program is NOT to be interactive (i.e. NO USER INPUT).

Since this is an interface i have a formation of a plan:

................................................................................interfaceOfCoins(Interface)

................................................................MetalClass(Parent class implements interfaceOfCoins)

Coin(Subclass extended to MetalClass )-----preciousCoinnt(Subclass extended to MetalClass)-----rareCoin(Subclass extended to MetalClass)

Is this plan solid so that i can create the simple interfaceOfCoins to the connect to MetalClass description of values (being the appropriate weight that will be in private of course) effecting the lower subclasses?

I've also been told that i can do as many coins as i need to get returned results (which i am questioning if i should put it in the client main or not, please give opinions about that thought and also for how many coins i should do, does 100 sound nice?). And lastly (As you can see in bold from the description) Am i going to have to create another interface for the flip or can i just create that in the interfaceOfCoins and describe that in all the coin Subclass's?

The reason for this is because i am mapping this out in my head and on paper, but my curiosity of having an interface being connected to a parents class is amazing to look at. (i'm reading a java book and it teachers you how to think in a certain way without having the combinations of java code being mentioned) This also needs to be properly cleaned, which i will supply what i have after i shown how far i reached. Also, making a year i do not know when to start. either perhaps a random form of the 1600 till now and what about there face value? (the is racking my mind so bad right now)


Would also appreciate some helpful code in parts so that i am doing it correctly, will update with results to show how i am doing once i get responses on here. : )

You coders are amazing people to work with.

P.s i think i'm getting sick (as in ill from headache and cough) from this program. I would like some help please, this feels too much in a way ^ ^;
 
Kyle Grady
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what i could com up with based on my current condition of sickness. Being ill and coding does not serve well for me.

interfaceOfCoin



MetalClass


Coin


preciousCoin


rareCoin
 
Campbell Ritchie
Marshal
Posts: 56597
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read the instructions carefully. It tells you which classes and which interfaces to create. You have created different classes. Apart from the spelling errors: rareCoin should read RareCoin.


If you are feeling ill, rest and stop coding altogether.
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have an idea of TDD then try to use TDD. Its great. Junilu taught me this thing. Its helps me lot. I am trying to implement the same every where
i can.
 
Kyle Grady
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tushar Goel wrote:If you have an idea of TDD then try to use TDD. Its great. Junilu taught me this thing. Its helps me lot. I am trying to implement the same every where
i can.


Never heard of TDD, what is it?
 
Kyle Grady
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone give me a hand on how this program should work and look in code, i really want to learn how this code but since i'm sick this hinders me now how the cods should be typed.

Can anyone assist, please?
 
Anthony Valdez
Greenhorn
Posts: 4
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry to hear you are sick Kyle. I could be wrong, but are you looking for someone to write the code for you? I came to Code Ranch because I knew they wouldn't just hand me the answer. They would help me get to the answer by offering suggestions and teaching me the correct way to go about coding. If you are looking for someone to just hand you your needed code, I do not believe this is the place for you. You are making progress, but it seems your sickness may be hindering your ability to think clearly to write your code. If I were you, I'd take the already given advice by Campbell... "If you are feeling ill, rest and stop coding altogether."
 
Campbell Ritchie
Marshal
Posts: 56597
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TDD means test driven development.

If you are ill, as I said earlier, you should rest. And get somebody to notify you as being ill.
 
Kyle Grady
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I realy do appreciate, everyone's hard work to help me - well there is no way i can make this up.

Sucks that when it comes to coding its either you pass or fail - there is no sick day. Haha.

Ps. You guy's do give me the answer, do to me having different way's of tackling this you say "Try this", and it works. So again really appreciate it.
 
Kyle Grady
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well i finished it, this is what i have.


The only problem is, how do i make the main to call the interface or construct the object normally?


Here is my code, what i made when sick. XP


InterfaceOfCoin




MetalClass


Coin


preciousCoin


rareCoin
 
Campbell Ritchie
Marshal
Posts: 56597
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Minus 15 marks because there is no Flippable interface.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!