Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Mcposie

  • one year ago

Hi everybody, I am a bit of a noob to the site and need some help understanding classes. I have got up to Homework 3, Exercise 3.6 without much bother, but now I'm not even sure what the question is asking. As far as I understand it initializing a class is defining the kind of attributes its objects can have. So for a FIFO queue what kind of attributes would that be? Would each item in the queue be a separate object/instance? If anyone has any ideas or helpful links it would be so appreciated! Thanks guys!

  • This Question is Open
  1. Mcposie
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Sorry I thought this was going in the Intro to Python section, but if you guys can still help, the question is to create a class Queue that creates a first in first out list of items. I think my problem more though is that I just basically dont understand what on earth a class is. Why wouldn't you just use a list and pop the top answer?

  2. diomit
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    From noob to noob.. ;) You don't want to create a list because the class allows you to give attributes to your object. Im not on the hw3 yet but what you can do with a class is that your first item could bear the attribute 'first', your list would go through a calculation (of the first) each time. A class allows you to create 'object' with specifications that a list can't be aware, when your class will : The difference between 95% water with some minerals and a human being. Same materials but one is easier to talk with. The chapter 12 of thinkcspy is quite clear if you didn't get the chance to read it yet.

  3. rsmith6559
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    A class is a design, containing attributes and actions (functions/methods) that an object has. Objects are created from a class, this is called instantiation. In the case of a Queue class, it would have an array, list or tree to store whatever is in queue. You'd have public methods (can be called by the programmer using your class) that would add to the queue, remove from the queue and maybe report how many items are in queue. You'd have private methods (the programmer using your class doesn't have access to these) to manage your storage.

  4. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.