» »

[Java] Nejasna naloga

[Java] Nejasna naloga

draciel ::

Ok, imam eno prijateljico z Danske, ki je šla na faks in so se začeli učiti javo. Vse lepo in prav. Ona me prosi za pomoč, in mi iz danščine prevede v angleščino njihovo nalogo, kaj profesor od njih zahteva. Bom kar kopiral..

The car have to know when it have been washed last time. 

(search on internet for the right datatype to keep this value)

there have to be a method "addDays" which add a number of days. When then you call this method it tells us x (number of days) has past, where the "x" indicates the number of days to simulate that the time is "moving"

There have to be a different on how often different colors of cars have to be washed.

There have to be a method which investigate wheter a car have to be washed "today" (okay it means that it tellt us if it need to be washed "today" or it dont have to... its the if/else thingy)

Set a max of number of times a carwash can wash cars before it have to get filled with soap again. if the limit is getting exceeded, cant cr get washed anymore though you're trying to wash the car


Men je ta naloga popolnoma nejasna. Sicer to so osnove in nalogo bi znal rešit ker ni težka sam ne razumem.. na primer..

The car have to know when it have been washed last time. (search on internet for the right datatype to keep this value)

- Avto nima možganov. Avto ne more vedeti kdaj se je zadnjič opral.

there have to be a method "addDays" which add a number of days. When then you call this method it tells us x (number of days) has past, where the "x" indicates the number of days to simulate that the time is "moving"

Ok, potrebujemo metodo "addDays", katera doda število dnevov. Ok razumem, metoda ti pove koliko dnevov je preteklo od zadnjega pranja mogoče? To navodilo se nanaša na prvo navodilo.

There have to be a different on how often different colors of cars have to be washed.

-Wtf?

There have to be a method which investigate wheter a car have to be washed "today" (okay it means that it tellt us if it need to be washed "today" or it dont have to... its

Wtf? Če ti pripelješ avto v avtopralnico ga bo stroj opral takoj. Ne pa da se bo odločal ali ga bo danes opral ali ne. Na podlagi česa se mora program odločiti ali ga bo opral ali ne? Je umazan/čist?

Razumem da je mogoče malo slabo prevedla, vendar v tej nalogi po mojem mnenju manjkajo podatki ali pa jaz preveč slabo razumem no.

draciel ::

The car have to know when it have been washed last time.

Ok narediš npr set metodo in nato get metodo , ki vrne recimo dan v mesecu. Npr 15.

there have to be a method "addDays" which add a number of days. When then you call this method it tells us x (number of days) has past, where the "x" indicates the number of days to simulate that the time is "moving"

Metoda "dodajDneve", ki doda število dnevov. X mora pa biti dinamičen ( se pravi se spreminjat ). Praktično imam tukaj samo eno vrednost in to je dan v mesecu. Drugega tukaj nimam. (Kakšnega objekta ki predstavlja današnji dan pa ne smem uporabiti ). Kam naj torej seštevam potem..

mah...

mgermo ::

Al pa če ji prevajanje ne gre ravno od rok...

draciel ::

ja tud mogoče. sam mi je poslala nalogo v danščini in google translate je prevedu podobno. tko da drugih informacij sigurno tud ni podanih.. mogoče je tud profesor jeben, če že 3 dni rešujejo to nalogo. 25ljudi(30) je pogrnilo pri nalogi:

"Ustvari razred user s fieldi(name,age) in ne dovoli da se ustvari objekt dokler nista določeni te dve vrednosti"

Rešitev: Ustvariš pač konstruktor s parametri name in age. Tako ti "overrida" default konstruktor in naredi novega, obenem ti vrednosti ne bo pripisalo če argumentov ne izpolniš.
In sedaj se zamisli. 25ljudi ni znalo tega rešiti. Sicer ni problem v njih, temveč v profesorju.

lol

roba87 ::

Konstruktorji niso normalne metode in ne morejo bit "overridden".

draciel ::

Rad bi samo nekaj razčistil..Imam preprosto nalogo, ki zahteva od mene naj naredim en superclass, pa 2 dedovana razreda. Superclass razred ( je abstrakten ) vsebuje 3 ne privatne fielde, ter setmetodo(abstraktna), ter display metodo (abstraktna) za 1 določen field. 2 druga fielda nastavim v konstruktorju. tisti field, ki potrebuje setmetodo pa itak naloga od mene zahteva naj nastavim v konstruktorju tudi.

Na koncu želi od mene da naredim child objekte in prikažem njihove vrednosti.

Zakaj naloga zahteva metodo v subclassu, ker tako ali tako lahko prikažem podatke v subclassu preko display metode. fieldi so pa itak dedovani ter nastavljeni v konstruktorju tako da podatke vedno brez problema prikažem. Še naloga..

/*Write an application named UseChildren that creates and displays at least two
Child objects--one Male and one Female. Child is an abstract class and Male and
Female are subclasses. The Child class contains fields that hold the name, gender,
and age of a child. The Child class constructor requires a name and a gender. The
Child class also contains two abstract methods named setAge() and display().
The Male and Female subclass constructors require only a name; they pass the
name and appropriate gender to the Child. The subclass constructors also
prompt the user for an age using the setAge() method, and then display the
Child's data using the display() method.*/

hexor ::

Če prav razumem imaš metodi za izpis in za nastavljanje vrednosti abstraktne, torej mislim da bi jih glede na to moral v vsakem podrazredu omeniti in redefinirati po pravem...
RootMachine ;)


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

Skripal (strani: 1 2 3 )

Oddelek: Loža
13131615 (17364) Pac-Man

SpaceX reusable rockets (nova tema)

Oddelek: Znanost in tehnologija
294493 (3673) BigWhale
»

Nokia n95 8GB verzija (strani: 1 2 )

Oddelek: Mobilne tehnologije
9214590 (2724) gasperxp
»

Apache - localhost JA, IP naslov NE

Oddelek: Omrežja in internet
186590 (6449) ManDriver

Več podobnih tem