lewashby 56 Junior Poster

So even if I declare a variable preceded with the keyword "float", it will still be read as double if I don't tack an "F/f" to the end?

The reason is perhaps strangely enough quite simple!
C# interprets literals like 234.123 as a double and not as a float.
You cannot assign a double to a float directly.
So if you explicitly want to say that 234.123 is a float, you have to append an f or F to it.
The Math class also, only works with double types.

lewashby 56 Junior Poster

I'M reading "Head First C#" In this book I was told that when you want to create a float that you need to add an "F" to the end.

float myFloat = 14.6F;

But the very first thing you type is "float", isn't that enough?

lewashby 56 Junior Poster

I installed wine on my Ubuntu 9.10 and tried to run the 1998 game Thief. Everything started but the sound started to deteriorate winthin seconds until it was completely gone. Does anyone have any ideas?

Also, I noticed in the Wine menu that you can choose the version of Windows that you want to emulate. But what I'M trying to figure out, it that for installation, running the program, or both? Thanks for any and all responses.

lewashby 56 Junior Poster

I recently learned about a good media player for Ubuntu called Songbird.
I downloaded the .tar.gz file from http://www.getsongbird.com/, and unloaded it to my desktop. I read from one of the post on the site that I needed to move it to my home folder and just click on the songbird file. This has failed. Nothing happens. I see three files by the name "songbird", songbird, songbird.ini, & songbird-bin. The ini file opens up text, the -bin file does nothing, and the songbird file ask me "Run in Terminal - Display - Cancel - Run". But I'M not having any luck with these options either. Thanks for any all all help.

I also found a dep package out there somewhere but once it installed I couldn't get it to load, it would just start to open and then, nothing.

lewashby 56 Junior Poster

I have a desktop with no monitor and a lap top. I've purchased a cable to connect from the back of my desktop to my laptop so I could have access to my desktop, but I don't know how to make my laptop display the contents there in. Thanks for any replies.

lewashby 56 Junior Poster

I have a desktop with no monitor and a lap top. I've purchased a cable to connect from the back of my desktop to my laptop so I could have access to my desktop, but I don't know how to make my laptop display the contents there in. Thanks for any and all replies.

lewashby 56 Junior Poster

I have a little programming experience and I'M just getting into Linux. I was wondering, how big of a deal would it be to convert some of your old classics like Half-Life and Tomb Raider from Windows to Linux? Sorry to ask such a stupid question on such a technical forum.

lewashby 56 Junior Poster

I'M wanting to get a new computer, not a typical computer from Wal-Mart or BestBuy. I want to run Linux, Windows 7, and Windows 98. Since this will be a desktop I can add new hard drives as I see fit, but here's my question. What's the best way to run multiple OSes and computer. If I have multiple hard drives, can the different OSes be on different drives, or should they all be on one drive in different partitions. I would prefer both Windows to be on the same partitioned drive and Linux and it's own drive. But I don't know how this would work out with the master/slave setting for the hard drives. Thanks for any and all help.

lewashby 56 Junior Poster

I'M trying to edit my back.bashrc file with the following aliases, but it want let me save it, only Save As. Also, I don't really know where in the file I could place these lines.

alias rm-'rm -i'
alias cp='cp -i'
alias mv=mv -i'

Thanks

lewashby 56 Junior Poster

I'M reading a book on C#, here is some of the code.

public BitterCritter(): base("", 2, 2, 0){}

I see that you can specify what attributes the child class inherits based on it's parent class through parameters. But what if you specify the base class but insert no parameters? Does it then it none, or all of the like the original class? Thanks.

One more thing, is it just me or are constructors in C# hard to see in the code. I first learned about constructors in python, where they were clearly surrounded by double underscores __MyConstructor__? Again, thanks.

lewashby 56 Junior Poster

I'M reading the book that's in the title. Let me show you what's going on.

I'M given the following code, an example of Inheritance.

using System;

namespace CritClone
{
    class CritViewer
    {
        static void Main(string[] args)
        {
            CritViewer cv = new CritViewer();
        }// end main

        public CritViewer()
        {
            Clone myClone = new Clone();
            myClone.name = "Dolly";
            Console.WriteLine(myClone.talk());

            Console.WriteLine("Please press Enter to continue");
            Console.ReadLine();
        }// end constructor
    }// end critviewer
}// end namespace

And then the next page gives me this part.

using System;

namespace CritClone
{
    public class Clone : Critter
    {
        // nothing here
    }
}

But it looks to me like it's two different files that have no connection. Also, did I miss the creating the talk() method? I don't understand what's going on here, the book seems to be going all over the place and I'M unable to follow. Am I doing something wrong?

lewashby 56 Junior Poster

Does your Mono IDE not contain some example files, or readme files, to get you started?
The most basic file I can think of is

class Hello
{
    public static void Main()
    {
        System.Console.WriteLine("Hello world!");
    }
}

You should be able to compile and run this little gem.

Yea, I can run that gem. But what I need is a way to interact with my program. For instance, Console.Readline(). There's not way for me to interact using the new text program output.

lewashby 56 Junior Poster

http://ironpython.codeplex.com/releases/view/12482

I'M running Ubuntu 9.10. On the website above, what which download should I use? I don't see a debian so I'M assuming I need to get the bin. If that's the case, I have no idea how to install a bin. Thanks for any and all replies.

Wait, it's not for Linux, is it?

lewashby 56 Junior Poster

I'M used to using a DOS bases screen but I don't know how to get my code a run in that kind of a Window. How do I use the default Application Output? I don't know how to input information, you now like with a Console.ReadLiine(). It's just a regular text based screen and there's no where to input information. Thanks.

lewashby 56 Junior Poster

Quit replying to my threads, you're no help. Besides, that's the second time you've answered my question with the same stupid answer.

lewashby 56 Junior Poster

I want to run my programs in a traditional Dos based screen as opposed to the new text page that it's running in now. Does anyone know how I can do that? Thanks.

lewashby 56 Junior Poster

If anyone is interested in bringing iTunes to linux, there is a group on facebook called "iTunes for Linux", please join. Also, this is apples feedback page.

http://www.apple.com/feedback/itunesapp.html

lewashby 56 Junior Poster

Is there a way that I can run my C# code in a traditional dos based screen unlike the white background my programs are running in at the moment? I looked though the preferences but couldn't find anything. Thanks.

lewashby 56 Junior Poster

The package manager of your distro is there to handle and resolve dependencies. Now, if you want to use debian packages, install first a debian package manager (something like gdebi on ubuntu) because just unpacking won't work. Or, from the command line, you can use dpkg -i (check out the man pages -> man dpkg.)

I was using gdepi when I got that error message.

lewashby 56 Junior Poster

I'M new to Linux & Ubuntu. I know I could just install Open Office through the Ubuntu Software Center or the Package Manager but I wanted to do it manually. So I download the debian package from www.openoffice.org and unzipped it. Now I have a folder on my desktop lapeled "OOO310_m19_native_packed-1_en-US.9420" Inside that folder there are 48 .deb files and a sub folder named "desktop-integration" and within that folder is one file name "openoffice.org3.1-debian-menus_3.1-9420_all.deb". But none of the .deb files I try to run will work. I'M getting errors.

Error: Conflicts with the installed package 'openoffice.org-core'
Error: Dependency is not satisfiable: ooobasis3.1-core01

Now I did uninstalle the version of Open Office prior to trying this. Thanks for any and all replies.

lewashby 56 Junior Poster

I'M trying to learn to program through Mono. I'M using a book on C#. Although it isn't specifically for Mono, I haven't gotten far into the book and it's a really small example so I don't expect that it has any platform specific code. Please see what's wrong with this code.

namespace Song
{
	class ThisOldMan
	{
		static void Main(string[] args)
		{
			doVerse(1);
			doChorus();
			doVerse(2);
			doChorus();
		}
		
		static void doChorus()
		{
			string message = "";
			message += "\n...With a knick-knack paddy whack\n";
			message += "Give a dog a bone\n";
			message += "This old man came rolling home.";
			message += "\n\n";
		} // end doChorus
		
		static void doVerse(int verseNum)
		{
			string message = "";
			message += "This old man, he played ";
			message += verseNum;
			message += ", \nHe played knick-knack ";
			message += getPlace(verseNum);
			
			Console.WriteLine(message);
		} // end verse
		
		static string getPlace(int verseNum)
		{
			string message = "";
				switch(verseNum)
			{
			 case1:
				message = "on mu thumb ";
				break;
			 case2:
				message = "on my shoe ";
				break;
			default:
				message = "not yet defined";
				break;
			} // end switch
			return message;
		} // end getPlace
		
		static void pause()
		{
			Console.ReadLine();
		}
	}
}
lewashby 56 Junior Poster

I downloaded and unziped the Open Office Debian package to my Ubuntu desktop. Inside the folder there are a lot of .deb file and one sub folder with another .deb inside. That one being by itself I assume that would be the right one so I tried to install it and this is what I got.

Error: Conflicts with the installed package 'openoffice.org-core'

Thanks for any and all replies.

lewashby 56 Junior Poster

Resolved, I figured it out.

I'M getting the following error when I try to install mono on my Ubuntu OS using apturl.

Failed to run /usr/sbin/synaptic '--hide-main-window' '--non-interactive' '--parent-window-id' '62914563' '--set-selections-file' '/tmp/tmpyUj0VR' as user root.

The underlying authorization mechanism (sudo) does not allow you to run this program. Contact the system administrator.

lewashby 56 Junior Poster

I'M just getting started with Linux and I'M using Ubuntu. Straight from the CD Ubuntu came loaded with Open Office - Word, Spreadsheet, & Presentation. But how do I get the whole Open Office package? And what happens with the ones already on my system? Do I need to remove them first? Thanks for any and all replies.

lewashby 56 Junior Poster

So I've downloaded the Ubuntu ISO and burned it to a CD. I want to install it along side my current Windows OS with a bigger partition. Can some one please give me some help on how to go about doing that. I know I restart my computer with the CD in the drive, but what options should I select during the installation. I know it should be simple, but I don't want to screw this up. I know one thing I usually ask is about the format, and I have no idea. Thanks for any and all help.

lewashby 56 Junior Poster

I'M currently running Vista but am trying to move at least 90% of my computer usage to Linux so I've download Ubuntu. So I burned the ISO to a CD and now I need to know how to install it but give it a separate bigger partition than my Windows. Thanks.

lewashby 56 Junior Poster

Think of it as an extra layer of misdirection :)

If you code in any kind of organization (or even if you don't), you will inevitably have 180 different Print methods in different classes, some of which will be named Output (just for sake of argument).

Now say 16 divisions got together on a project and pooled all their class resources together into one megaproject. People would be trying to call Print() and getting all kinds of results. You can encase your classes in a namespace (not completely unlike encasing your methods in a class) and be able to tell them apart.

So you can have the output class of production be Production.Output and the Print method be accessed as Production.Output.Print(). If someone wants to use a particular method they can call it by it's fully qualified name. If you know that you're just using the class or method within your own division, you can put a using Production.Output; at the top of your code (conventionally, I suppose it can be anywhere before you call the method, but I may be incorrect about that).

As to your specific question, you can and will have a namespace that crosses multiple files. For instance when you create a winforms application you get a Form1.cs, Program.cs, the design files, etc. that all share a common namespace by default. It's not necessarily a collection of files but for example a certain subset of a dll's classes might have it's own …

lewashby 56 Junior Poster

I'M trying to learn to program through C#. The book I'M reading is trying to explain namespaces but I'M failing to understand it. As I understand it, a class is a blueprint for an object and, and a class is just a special block of code. So what exactly is a namespace, can I navigate through my windows explorer and see on? Is it actually a C# file, or a collection of C# files? Thanks.

lewashby 56 Junior Poster

http://www.mono-project.com/Main_Page
On that site, what is the difference between to two blocks to the left? They read.
Mono
An open source, cross-platform, implementation of C# and the CLR that is binary compatible with Microsoft.NET

MonoDevelop
An open Source C# and .NET development environment for Linux, Windows, and Mac OS X

Secondly, is there a way to download Mono on a Windows machine that runs in the background without also downloading the C# IDE?

One more thing. If I were to write a program on Linux with and for Mono, wouldn't that program also work on Windows & Mac providing they also had Mono installed? Thanks.

lewashby 56 Junior Poster

Yep mono is the way to go, and you don't need .NET installed. It's already installed on ubuntu and used by many app (tomboy, fspot & banshee). But before coding you will need to install monodevelop.

It's worth looking at these tutorials.

Thanks, I found both of you links very helpful.

lewashby 56 Junior Poster

I'M trying to switch from Windows to Ubuntu Linux. I'M trying to learn how to program and since I am also trying to move to Linux, thought that mono would be a good place for me to start. But I noticed when I installed mono (http://www.mono-project.org), it said I needed .NET(on my windows machine). I thought mono was an open source counterpart to .NET, so why should it be required? What happens when I go to install mono on my Linux, you can't get .NET for Linux anyway can you?
So am I right assuming that the mono project with C# would be good place to start, considering I'M trying to move to Linux?
Thanks

lewashby 56 Junior Poster

I'M trying to make the switch from Windows to Linux, or at least make it a 9 to 1 ratio. I mean, I can't completely do away with windows for several reasons. I'M also interested in programming. Now, Linux is suppose to be a much better OS and that seems to be the OS that most programmers prefer. But what I'M trying to figure out is, why is there so many different versions of the same program for so many different distributions? Doesn't that make it harder on the programmer? And I would think that programs should work on all of them anyway. I thought the different distributions just came loaded with different programs from the start and each distribution had a different GUI. Please explain. Thanks.

lewashby 56 Junior Poster

I posted a thread labeled pygame, global name "glob" but am unable to resolve the issue so I was just going to ask a few question about the code. Well first of all, I ran it on Windows Vista, python 2.6 and pygame, but I'M not sure what version of pygame.

Anyway, in the line font = pygame.font.SysFont("arial", 16), I look up font and I see it's a module named font.py. But in that file, I don't see a calls or function by the name of SysFont. Can anyone please tell me why? Thanks.

lewashby 56 Junior Poster

I'M reading "Beginning Game Develpment with Python and Pygame". In the following code, I'M gettin this error in sysfont.py

NameError: global name 'glob' is not defined

import pygame
from pygame.locals import *
from sys import exit

pygame.init()

SCREEN_SIZE = (800, 600)
screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32)

font = pygame.font.SysFont("arial", 16)
font_height = font.get_linesize()
event_text = []

while True:
    
    event = pygame.event.wait()
    event_text.append(str(event))
    event_text = event_text[-SCREEN_SIZE[1] / font_height:]
    
    if event.type == QUIT:
        exit()
        
    screen.fill((255, 255, 255))
    
    y = SCREEN_SIZE[1] - font_height
    
    for text in reversed(event_text):
        screen.blit( font.render(text, True, (0, 0, 0)), (0, y) )
        y -= font_height
        
    pygame.display.update()

Thanks for any and all replies.

lewashby 56 Junior Poster

First of all I'M using Ubuntu and I'M new to it, trying to make the switch. I'M reading a book on Ubuntu but it's a little out of date to the one I'M running. Anyway, the book instructs me to go to > System > Administration > Synaptic Package Manager, and then > Settings > Repositories. At this point I'M told to click on the Installation Media Tap, the closes thing I see on my version is " Third-Party Software". So I click it. Where I am instructed to click the Add button the Repository dialog. But when I click it, I get this.

Enter the complete APT line of the repository that you want to add as source
The APT line includes the type, location and components of a repository, for example 'deb http://archive.ubuntu.com/ubuntu/ jaunty main'.
APT Line: TEXT AREA HERE

Can someone please give me a hand on this, thanks.

P.S. what's the difference between Add/Remove programs and the Synaptic Package Manager anyway. Can't you just go to the websites and download the programs directly?

lewashby 56 Junior Poster

In the following code, I don't understand the line , print tank_name, tanks[tank_name]. What I'M having trouble with is it seems a little redundant, print thank_name, then thanks(the name of the dictionary), then tank_name again. And why is the second tank_name in "[]" like a list? I can't remember, is that just how you use a dictionary? Thanks for any and all replies.

from tank import Tank

tanks = {"a": Tank("Alice"), "b": Tank("Bob"), "c": Tank("Carol")}
alive_tanks = len(tanks)

while alive_tanks > 1:
    
    print
    for tank_name in sorted( tanks.keys() ):
        print tank_name, tanks[tank_name]
lewashby 56 Junior Poster

Thanks, some how that went right over my head while reading the my python book. But showing them one right on top of the other really cleared that up for me. Thanks.

lewashby 56 Junior Poster

In the following program, what is the "values" function?

for tank in tanks.values():
    if tank.alive:
        print tank.name, "is the winnter!"
        break

I looked it up using Wing IDE and this is what I found.

def values(self, arg):
    """ D.values() -> list of D's values """
    return []

Thanks for any and all replies.

lewashby 56 Junior Poster

In the following program, why do I need to use the name "player" rather than a regular counter like "i"? I ran the program this way and it prints out the last element in players for how ever many player elements are in players. I want to know what's going on behind the scenes, why is it choosing only the last element. Thanks.

# Simple Game
# Demonstrates importing modules

import games, random

print "Welcome to the world's simplest game!\n"

again = None

while again != "n":
    players = []
    num = games.ask_number(question = "How many players? (2 - 5): ",
                           low = 2, high = 5)
    
    for i in range(num):
        name = raw_input("Player name: ")
        score = random.randrange(100) + 1
        player = games.Player(name, score)
        players.append(player)
        
    print "\nHere are the game results:"
        
    for player in players:
        print player
            
    again = games.ask_yes_no("\nDo you want to play again? (y/n): ")
        
raw_input("\n\nPress the enter key to exit.")
lewashby 56 Junior Poster

In the program below, I have two questions. First, the first object, card1 passes the strings A & c to it's master class. What I want to know is, what do these two strings have to do with the A & c in RANKS & SUITS? If the class had been based the number of the element in RANKS & SUITS I wouldn't be confused right now but I don't see RANKS or SUITS being used.

Secondly, why is there an __init__ method inside the Positionable_Card class with rank and suit, but is then instructed to use rank and suit from it's base class? Thanks for any and all replies.

# Playing Cards 3.0
# Demonstrates inheritance - overriding methods

class Card(object):
    """ A playing card. """
    RANKS = ["A", "2", "3", "4", "5", "6", "7",
             "8", "9", "10", "J", "Q", "K"]
    
    SUITS = ["c", "d", "h", "s"]
    
    def __init__(self, rank, suit):
        self.rank = rank
        self.suit = suit
        
    def __str__(self):
        rep = self.rank + self.suit
        return rep
 

class   Unprintable_Card(Card):
        """A Card that won't reveal it's ran or suit when printed. """
        def __str__(self):
            return "<unprintable>"
        
        
class Positionable_Card(Card):
    """ A Card that can be face up or face down. """
    def __init__(self, rank, suit, face_up = True):
        super(Positionable_Card, self).__init__(rank, suit)
        self.is_face_up = face_up
        
    def __str__(self):
        if self.is_face_up:
            rep = super(Positionable_Card, self).__str__()
        else:
            rep = "XX"
        return rep

    def flip(self):
        self.is_face_up = not self.is_face_up
        
# main
card1 = Card("A", "c")
card2 = Unprintable_Card("A", "d")
card3 = Positionable_Card("A", "h")

print "Printing …
lewashby 56 Junior Poster

I noticed when I first got my new Toshiba Satellite that there was some strange behavior with it's keyboard. When typing in a text document, the cursor would just jump to a random position in the text document, and no it wasn't be accidentally touching the touch pad. Then one day I went to login to my Windows vista account and noticed that when I typed the numbers for my password it would insert two characters instead of one. I don't know what other characters it would insert of course because they are hidden. This problem is also affecting my Linux Ununtu. When I go to login, I have to use the num-lock pad on the right or else I can't type in the correct characters. And what's worse, even when I press the letter "e" in Ubuntu, it doesn't type "e", but instead tries to take a screen shot. But a capital "E" works just fine. Does anyone know what's going on? I really don't want to wait two months for my computer to be sent off fixed and then returned by Toshiba. Thanks for any and all responses.

lewashby 56 Junior Poster

I'M 24 years old, a single parent in TN. I've been very interested in programming since I as probably 15, and I've been trying to learn since then. I started out with C++, didn't get far. I would start, give up, and start again. About a year ago I started C#, and now Python. I read somewhere that database programmers make good money and are always in demand. What I'M trying to figure out is, how do I get tech job? What's the fastest thing I could learn, or at least the best of both worlds. I work in a factory, no heat, no AC, where I've been for over 5 years. What's tacking me so long to learn what I need to learn to get the job? As I mentioned, I'M a single parent so going back to school isn't an option. Maybe something quick I could do online, but not something that's going to take as long as an actual degree. Please help.

lewashby 56 Junior Poster

In the following program, the second line in main print "Printing a Card object:", is not showing up when I run the program. Could someone please tell me what's going on? Thanks.

# Playing Cards
# Demonstrates combining objects

class Card(object):
    """ A playing card. """
    RANKS = ["A", "2", "3", "4", "5", "6", "7",
             "8", "9", "10", "J", "Q", "K"]
    
    SUITS = ["c", "d", "h", "s"]
    
    def __init__(self, rank, suit):
        self.rank = rank
        self.suit = suit
        
    def __str__(self):
        rep = self.rank + self.suit
        return rep
    
class Hand(object):
    """ A hand of playing cards. """
    def __init__(self):
        self.cards = []
        
    def __str__(self):
        if self.cards:
            rep = ""
            for card in self.cards:
                rep += str(card) + " "
        else:
            rep = "<empty>"
        return rep
    
    def clear(self):
        self.cards = []
        
    def add(self, card):
        self.cards.append(card)
        
    def give(self, card, other_hand):
        self.cards.remove(card)
        other_hand.add(card)
        
# main
card1 = Card(rank = "A", suit = "c")
print "Printing a Card object:"
print card1

card2 = Card(rank = "2", suit = "c")
card3 = Card(rank = "3", suit = "c")
card4 = Card(rank = "4", suit = "c")
card5 = Card(rank = "5", suit = "c")

print "\nPrinting the rest of the objects individually:"
print card2
print card3
print card4
print card5

my_hand = Hand()
print "\nPrinting my hand before I add any cards:"
print my_hand

my_hand.add(card1)
my_hand.add(card2)
my_hand.add(card3)
my_hand.add(card4)
my_hand.add(card5)

print "\nPrinting my hand after adding 5 cards:"
print my_hand

your_hand = Hand()
my_hand.give(card1, your_hand)
my_hand.give(card2, your_hand)

print "\nGave the first two cards from my hand to …
lewashby 56 Junior Poster

Are you sure that you are not accidentally touching the glide pad with your thumbs [or similar] as you type?

It happens to me to and I find it really annoying [but my keyboard is NOT haunted/possessed]

Yes, I'M sure that's not it. Someone please help.

lewashby 56 Junior Poster

In the following program, why is "Ac" the first thing that the program outputs? In main, print "Printing a Card Object" is the first think I see that should print anything.
Is it the __str__ method using the rank & suit attributes from the __init__ constructor?

# Playing Cards
# Demonstrates combining objects

class Card(object):
    """ A playing card. """
    RANKS = ["A", "2", "3", "4", "5", "6", "7",
             "8", "9", "10", "J", "Q", "K"]
    
    SUITS = ["c", "d", "h", "s"]
    
    def __init__(self, rank, suit):
        self.rank = rank
        self.suit = suit
        
    def __str__(self):
        rep = self.rank + self.suit
        return rep
    
class Hand(object):
    """ A hand of playing cards. """
    def __init__(self):
        self.cards = []
        
    def __str__(self):
        if self.cards:
            rep = ""
            for card in self.cards:
                rep += str(card) + " "
        else:
            rep = "<empty>"
        return rep
    
    def clear(self):
        self.cards = []
        
    def add(self, card):
        self.cards.append(card)
        
    def give(self, card, other_hand):
        self.cards.remove(card)
        other_hand.add(card)
        
# main
card1 = Card(rank = "A", suit = "c")
print "Printing a Card Object"
print card1

card2 = Card(rank = "2", suit = "c")
card3 = Card(rank = "3", suit = "c")
card4 = Card(rank = "4", suit = "c")
card5 = Card(rank = "5", suit = "c")

print "\nPrinting the rest of the objects individually:"
print card2
print card3
print card4
print card5

my_hand = Hand()
print "\nPrinting my hand before I add any cards:"
print my_hand

my_hand.add(card1)
my_hand.add(card2)
my_hand.add(card3)
my_hand.add(card4)
my_hand.add(card5)

print "\nPrinting my hand after adding 5 cards:"
print my_hand

your_hand = …
lewashby 56 Junior Poster

I have a pretty new Toshiba Satellite laptop. When I first go the thing I noticed that in the middle of me typing something on a text based document that the cursor would jump to some random position in the text document. This of course caused what I was typing to be in the wrong spot. Not the problems seems to be getting worse. When I type the "@", it also inserts a "|", along side it. Like this "|@". The worst part is, it's affecting my login screen, I have to use the num-lock pad just to login, and I can't login to one of my user names at all. When I click the letter for the password, it acts like I pressed TAB.
I thought this might just be a windows problem but it also happened when I tried to login to my ununtu linux user account. I read on a forum that this could be fixed by turning off num-lock in the bios. But I haven't found it yet, all I found was keyboard wake on/off. Please help, thanks for any and all replies.

lewashby 56 Junior Poster

Does anyone know where I can find some sort of UML (unified modeling language) tool for python? I think it might help me understand OOP a little better, but I don't really know, I just read about UML and that's all I know. Thanks.

lewashby 56 Junior Poster

In the following program, how does the value of crit_name, end up in the self.name = name value? Is it because it's passed to that class and name is the only value in the __init__ parameter that has no default value? Thanks.

# Critter Caretaker
# A virtual pet to care for

class Critter(object):
    """A virtual pet"""
    
    def __init__(self, name, hunger = 0, boredom = 0):
        self.name = name
        self.hunger = hunger
        self.boredom = boredom
        
    def _pass_time(self):
        self.hunger += 1
        self.boredom += 1
        
    def _get_mood(self):
        unhappiness = self.hunger + self.boredom
        
        if unhappiness < 5:
            mood = "happy"
        elif 5 <= unhappiness <= 10:
                mood = "okay"
        elif 11 <= unhappiness <15:
                mood = "mad"
        else:
            mood = "mad"
        return mood
    
    mood = property(_get_mood)
    
    def talk(self):
        print "I'm", self.name, "and I feel", self.mood, "now.\n"
        
        self._pass_time()
        
    def eat(self, food = 4):
        print "Brruppp. Thank you."
        
        self.hunger -= food
        
        if self.hunger < 0:
            self.hunger = 0
        self._pass_time()
        
    def play(self, fun = 4):
        print "Wheee!"
        
        self.boredom -= fun
        
        if self.boredom < 0:
            self.boredom = 0
        self._pass_time()
        
def main():
    crit_name = raw_input("What do you want to name your critter?: ")
    crit = Critter(crit_name)
    
    choice = None
    
    while choice != "0":
        print \
        """
        Critter Caretaker
        
        0 - Quit
        1 - Listen to your critter
        2 - Feed your critter
        3 - play with your critter
        """
        
        choice = raw_input("Choice: ")
        print
        
        # exit
        if choice == "0":
            print "Good-bye."
            
        # listen to your critter
        elif choice == "1":
            crit.talk()
            
        # feed your …
lewashby 56 Junior Poster

In the following code, could someone please explain these if statements? elif 5 <= unhappiness <= 10:, & elif 11 <= unhappiness <15:, they have two arguments, one on each side which is something I haven't seen before. Also, what the one to the far right for anyway? Also, this program contains an endless loop if someone happens to find it please let me know. Thanks.

# Critter Caretaker
# A virtual pet to care for

class Critter(object):
    """A virtual pet"""
    
    def __init__(self, name, hunger = 0, boredom = 0):
        self.name = name
        self.hunger = hunger
        self.boredom = boredom
        
    def _pass_time(self):
        self.hunger += 1
        self.boredom += 1
        
    def _get_mood(self):
        unhappiness = self.hunger + self.boredom
        
        if unhappiness < 5:
            mood = "happy"
        elif 5 <= unhappiness <= 10:
                mood = "okay"
        elif 11 <= unhappiness <15:
                mood = "mad"
        else:
            mood = "mad"
        return mood
    
    mood = property(_get_mood)
    
    def talk(self):
        print "I'm", self.name, "and I feel", self.mood, "now.\n"
        
        self._pass_time()
        
    def eat(self, food = 4):
        print "Brruppp. Thank you."
        
        self.hunger -= food
        
        if self.hunger < 0:
            self.hunger = 0
        self._pass_time()
        
    def play(self, fun = 4):
        print "Wheee!"
        
        self.boredom -= fun
        
        if self.boredom < 0:
            self.boredom = 0
        self._pass_time()
        
def main():
    crit_name = raw_input("What do you want to name your critter?: ")
    crit = Critter(crit_name)
    
    choice = None
    
    while choice != "0":
        print \
        """
        Critter Caretaker
        
        0 - Quit
        1 - Listen to your critter
        2 - Feed your critter
        3 - play with your critter
        """
        
    choice = raw_input("Choice: ") …
lewashby 56 Junior Poster

well you're almost right :)

(1)yes in this case, but if omit the underscores in the beginning and write it like this self.name = name, then self.name is not private anymore.
(2) self.__name is private to the outside world but you can use it in the class so I think this line doesn't use the get_name() method because you're calling a method which uses the private variable and you're not accessing the private variable directly.
(3) here crit.name uses the get_name method because you're accessing the class variable directly and since it is private it needs a get method.

As you mentioned in your comments name = property(get_name, set_name) allows a direct call to name, i.e. print crit.name calls the get_name method of the class which then returns the correct name .
You can rewrite the whole thing like this:

class Critter(object):
    """A virtual pet"""
    def __init__(self, name):
        print "A new critter has been born!"
 
        self.__name = name
 
 
    def get_name(self): #---------------------------------------reads a value to a private name?
        return self.__name
 
 
    def set_name( self, new_name ): #-----------------------------set's a value to a private name?
        if new_name == "":
            print "A critter's name can't be the empty string."
        else:
            self.__name = new_name
            print "Name change successful."
 
 
    def talk( self ):
        print "\nHi, I'm", self.__name
 
 
# main
 
crit = Critter("Poochie")
crit.talk()
 
print "\nMy critter's name is:",
print crit.get_name()
 
print "\nAttempting to change my critter's name."
crit.set_name( "" )
 
print "\nAttempting to change my critter's …