Save
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

Trabalho L.P

Trabalho L.P sobre JAVA 8.0

Português Código
Classe para armazenar dados de pessoas <html> <body> public class Person { public enum Sex {<br /> MALE, FEMALE<br /> } String name; LocalDate birthday; Sex gender; String emailAddress;<br /> // ...<br /> public int getAge() {<br />
Lista e iterator interfaces. Primeiro, vamos olhar para a parte da interface List que é relevante para a implementação iteradores. <html> <body>template <class Item><br /> class List {<br /> public:<br /> List(long size =DEFAULT_LIST_CAPACITY);<br /> long Count() const;<br /> Item& Get(long index) const;<br /> // ...<br /> } </bod
percursos que definem uma classe Iterator abstrata, que define a interface iterator. <html> <body>template <class Item><br /> class Iterator {<br /> public:<br /> virtual void First() = 0;<br /> virtual void Next() = 0;<br /> virtual bool IsDone() const = 0;<br /> virtual Item CurrentItem() c
Implementações Iterator subclasse. ListIterator é uma subclasse de Iterator. <html> <body>template <class Item><br /> class ListIterator : public Iterator<Item> { public:<br /> ListIterator(const List<Item>* aList);<br /> virtual void First();<br /> virtual void Next();<br /> virtual
A implementação de ListIterator. Ele armazena a lista junto com um _current índice para a lista: <html> <body>template <class Item> ListIterator<Item>::ListIterator ( const List<Item>* aList ) : _list(aList), _current(0) { } </body> </html>
Isdone verifica se o índice se refere a um elemento dentro da lista: <html> <body>template <class Item> bool ListIterator<Item>::IsDone () const {<br /> return _current >= _list->Count();<br /> } </body> </html>
Finalmente, CurrentItem retorna o item no índice atual. Se a iteração já tenha terminado, então lançar uma exceção IteratorOutOfBounds: <html> <body>template <class Item> Item ListIterator<Item>::CurrentItem () const {<br /> if (IsDone()) {<br /> throw IteratorOutOfBounds;<br /> } return _list->Get(_current);<br /> } </body> </html>
Usando os iteradores. Vamos supor que temos uma lista de objetos dos empregados, e nós gostaríamos de imprimir todos os funcionários contidos. A classe Employee suporta isso com uma operação de impressão. Para imprimir a lista, nós definimos uma operação void PrintEmployees (Iterator<Employee*>& i) {<br /> for (i.First(); !i.IsDone(); i.Next()) {<br /> i.CurrentItem()->Print();<br /> } } </body> </html>
Uma vez que temos iterators tanto para back-to-frontal e travessias para frente e para trás, podemos reutilizar esta operação para imprimir os funcionários em ambas as ordens. <html> <body>List<Employee*>* employees;<br /> // ... ListIterator<Employee*> forward(employees);<br /> ReverseListIterator<Employee*> backward(employees);<br /> PrintEmployees(forward);<br /> PrintEmployees(backward);<br /
SkipListIterator está em conformidade com a interface Iterador, a operação PrintEmployees também pode ser utilizado quando os empregados são armazenadas em um objeto SkipList. <html> <body>SkipList<Employee*>* employees;<br /> // ... SkipListIterator<Employee*> iterator(employees);<br /> PrintEmployees(iterator);<br /> </body> </html>
Created by: danielferreiram
Popular Portuguese sets

 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards