• Post Reply Bookmark Topic Watch Topic
  • New Topic

big exercise  RSS feed

 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have 10class +1 the main.
i have one class name : box (super class)
one class name : space// (this is include in box,there are parts of it) it has 2 fields power and areaspace.I call2 methods ho(){} em(){} .On this methods i system.out what ever i want messages
one class name : system //(this is include in box,there are parts of it) it has 2 methods yo(){} lo(){} .On this methods i system.out what ever i want messages
one class name : ownerofbox//(this is include in box,there are parts of it) on this name i have field name ,surname ,adress

one class name : ball (extends from box) . numbers of different design
one class name : phone(etends from box).a field only number buttons
one class name : pc(extends from box) .something that show if it has near of it another pc
every object of it include newOwner(){} and the type(){} .On the type(){} needs messages for the new owner ."You good <owner name>" for objects phone.
the messages for ball:"this is a < x> <owner name>" (on x there is design).
For the objects pc message is :"You need change <owner name>"

one class name :hio(extends from pc)//i change the name of the mark of the pc and down the same
one class name :son(extends from pc)
one class name :kon(extends from pc)
hlio is for working ,son is for fun , kon is for games.
On my main program : there is a buisness that it has P boxes(the P should be given by command line or if not given by command line to be by UserInput).When all boxes will completed the user should give by keyboard how much are ball how much are phone and how much are pcs.This will be repeated until the add is different the P.All objects are initialized( by somes constructors) except of owenerofbox.
Find all costs of boxes and the categories(ball,phone,pc).This will be done by methods which will return if type is the ball ,if the type is phone ,or if is pc.The buisness will increase some categories: a)the phone that weight small and equal to 100 will increase 9% .If more than 100 will increase 20% and also this for pcs.When you done that you should appear a list with the new prices
 
Tim Cooke
Marshal
Posts: 4041
239
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks like homework. Nobody is going to do it for you but if you show us what you've done so far and tell us what specific part of that you're having trouble with then I'm sure you'll get some help.

So, do you have a question?
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never say that I request to solve it someone. When I will completed I will come with whole questions . I believe today night i will be finish it and I will come .Not to do one one question
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


1) did i do good that i create methods get,set and their private fields?I create constructor too. a)Constructor should have always the same name as the class is in?
2)on the other class i refer ball and phone .I should create the private field that it asks and get(){} and the set (){} method too?and constructor?
 
Carey Brown
Saloon Keeper
Posts: 3311
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Constructors are almost always declared to be public.
 
Carey Brown
Saloon Keeper
Posts: 3311
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got the basic jist but you need to be more consistent in following conventions.

getaddress() should be getAddress()

address() should be setAddress()

getLastname() should be getLastName()

variable Lastname should be lastName

variable Name should be name

variable names in general start with a lower case followed by camel case
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try not to place your constructor at the end of the class, that is unconventional, but not because of that. You need to know how objects being constructed before you move on with everything else.
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also .In my superclass i have a method i should change the old owner with the new owners .How could it be that too?
*on this method i should have parameter the new owner.I should transfer the old owner with the new owner and i should have message like that
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question number2 : As i have write up i have to do this things:
one class name :hio(extends from pc)//i change the name of the mark of the pc and down the same
one class name :son(extends from pc)
one class name :kon(extends from pc)
hlio is for working ,son is for fun , kon is for games.
something i am doing mistake i beleive ..
 
ekte spiriopoulos
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where have i mistake?
 
Tim Moores
Saloon Keeper
Posts: 4024
94
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use the quote functionality only for the relevant parts of what you're replying to, not for quoting entire posts. If you want to post something new, use the "Post Reply" button.

I've edited your previous posts to remove the superfluous quotations; I think the thread is much more readable now, don't you think?
 
Dave Tolls
Ranch Foreman
Posts: 3056
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

(and the same for 'kon')

That's trying to extend from itself.
The requirements say they should be extending from 'pc'.

If you have errors with your code you should also post the error messages here.
 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is something wrong about methods with a long list of things to print out. You can probably sort that all out by finding out how to write a toString() method←link not as good as I expected. Then you simply print out an object and toString is called for you.
 
Nigel Browne
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You getter methods shouldn't have an argument
 
Nigel Browne
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your newOwner class can not access the methods in class Owner. You neeed to instantiate an instance of class owner and then call the methods on the class instance.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!