carynb: (Wintertime)
[personal profile] carynb
They really meant it, didn't they?

The weather changes from beautiful blue sky to scads of snow in 30-second intervals.

The one constant? The wind howls.

I've finished my C# assignment, and have nothing else to do today until suppertime. It's a good day for curling up on the couch and doing nothing. I think I'll read a little, or knit a little, and just be glad I can stay inside.

Date: 2006-10-29 09:54 pm (UTC)
From: [identity profile] boywhocantsayno.livejournal.com
I'm curious (and confused :) ) about something... I finished the assignment yesterday, and it's working, but I'm not sure I've done it correctly (or, rather, the way we're supposed to do it :) ). I took [livejournal.com profile] thegrandepoobah's advice and read up on ArrayLists here, and used them to dynamically increase the size of my Student array as I added entries, but I'm not sure that we were supposed to do that. I'm thinking that we're supposed to use the Copy or CopyTo methods, since we've actually covered those in class, but I can't see how it can be done multiple times. For instance, I can create newStudentArray with a size one greater than StudentArray, copy StudentArray to newStudentArray, and add my new Student to newStudentArray, but that can only be done once, right? If I try creating a new StudentArray and copying newStudentArray back, I get "a local variable named StudentArray cannot be declared in this scope because it would give a different meaning to StudentArray, which is already used..."

Or are we just supposed to assume that the class has a maximum size, and disallow additional students from being added once that point is reached?

Also, I'm finding that I have to pass my Student array into each method that needs to access the whole thing, even within Main (for instance, ShowStudentMenu, which needs to loop through the Student array and list each student as part of the menu). But the specs would seem to indicate that those methods aren't supposed to take any parameters.

Date: 2006-10-29 10:53 pm (UTC)
ext_1749: Me (Default)
From: [identity profile] carynb.livejournal.com
I went with option B, and put a maximum class size in place. I didn't see any way to dynamically increase the size of the array, so I have a private variable MaxStudents that I've set to 100, but could be smaller. I hoped it would be easy enough to change that around if he mentioned something in class tomorrow on dynamically increasing arrays. He doesn't seem the type to throw in something that complicated without giving us information on it first, y'know? I was planning on asking him on Tuesday if we were supposed to do it that way, though.

I set up two classes, by the way - Student and aClass. I figured the Card/Deck sample we did in class was probably a good example to follow. I moved all my methods into my "aClass" class (I doubted I could have a "Class" class *g*), including all the menu functions, precisely because his prototypes didn't include passing the array (in my case, the aClass object) back and forth. The Student menu kinda needed to be there anyway, in order to produce the list of students to select.

Date: 2006-10-30 12:54 am (UTC)
From: [identity profile] boywhocantsayno.livejournal.com
I set up two classes, by the way - Student and aClass.

That occurred to me while I was in the shower this afternoon (I think of weird stuff at random times :) ), but I haven't tried it yet. I wasn't sure which way to go because the assignment itself doesn't say anything about setting up multiple classes - just the one Student class. I'll give it a shot and see if I can get it to work. (Which reminds me, I realized while looking over the Card/Deck program that the InitializeDeck method doesn't seem to have any kind of impact - if I comment out its code, the program still works because GetCardName and GetSuitName are operating directly on the random number selected. Main can't access my "cards" array that's set up in InitializeDeck. So obviously, while I'm getting the correct result, I didn't code it properly.)

(I doubted I could have a "Class" class *g*)

I thought C# was case sensitive. ;)

Even so, I wouldn't think it would be good programming practice to call a class "Class," just because of potential confusion.

Profile

carynb: (Default)
carynb

April 2015

S M T W T F S
   1234
567891011
1213141516 1718
19202122232425
2627282930  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 1st, 2026 10:48 am
Powered by Dreamwidth Studios