|
|
Well the OP in the title and the message talks of "Enumerations", and also wants to use things like A, A+, A- etc, so I thought enums probably would not do.
|
|
|
|
|
Yes, you can use enums to do exactly what the OP wants. Enums in Java are more than simple integers. They can have constructors, they can override methods from Object like toString(), they can have their own methods for specific processing and their own private variables, all sorts of clever things.
Lots of people talk about "enumerations" when they really mean "enumerated types". I guess that whoever set this exercise didn't think about that (shock horror, teachers are human too).
An Enumeration in Java is really just a sort of iterator. When they introduced the enum keyword into Java it broke a lot of existing code because it was common practice to call your Enumeration variable enum, because that is what all the Sun examples did, and all of a sudden that became a restricted name.
|
|
|
|
|
Yes, I was aware of this, having lived through the frustration of using enums in C++ but not having them in Java, while I was working on a JNI library for a multi-platform project.
|
|
|
|
|
Yes, you are right, I realized my mistake after people started using both terms. What I really want to do is use enumerated types to solve this problem, I just still can't wrap my mind around how to do it. I understand the concepts of enumerated types, just not the implications. I don't get how enumerated types use or even create its variables. If somebody could make perhaps a short replica of what needs to be done here, say just A+, A, and A-, and explain just what is actually going on during processing, I think I could finally get a better handle on these tricky enumerated types.
Thank you for all your comments so far! I seem to have really started a discussion lol.
|
|
|
|
|
I still need mega help on this >.<
|
|
|
|
|
|
OH I THINK I AM STARTING TO UNDERSTAND! If I let the user enter an integer as a grade, I could have an if statement that would send the correct letter grade to the class of the enum, and the enum would output the appropriate grade AND decide with a simple Boolean if the grade is passing or failing. IT ALL ADDS UP! Thank you so much for the help! I think I can finally do this problem!
I am assuming that enum is in its own class because I think that is what the teacher wants us to do :P. But I understand the logic you are using.
|
|
|
|
|
we're currently making a trial application that will display a swf on java.
Can we have some more info on how to load swf in java.
|
|
|
|
|
dfan23 wrote: Can we have some more info on how to load swf in java.
You really need to make a greater attempt to do some research for yourself before posting these questions. Use Google and search for Java and SWF.
|
|
|
|
|
|
How to return a value from one class to another class ?
|
|
|
|
|
dfan23 wrote: How to return a value from one class to another class ?
Quote Selected Text
I presume you mean instance rather than class, but in either case it is the parameter on the return statement from a method call.
|
|
|
|
|
|
use the compositionrelation between classes
one clase use another this is the best
|
|
|
|
|
I'm building my first Android app at the moment and it all seems to work well. I guess it's less complex than your average MS app but the help seems helpful and all the methods seem to be explained well.
I've got one issue with debugging which is driving me mental though.
I haven't installed the source for android so if I cause an error inside the framework the debugger reports that it can't find the source. Now, i could install the source and point the debugger to where it's living and then I'd get the code to break inside the framework code but what I'd rather do if it's possible is to get the code to break at the last point in my code before it enters the framework (most of these errors are caused by things like typos of DB fieldnames). Does anyone know if this is possible and if so how I can do this?
Cheers
Russ
|
|
|
|
|
Hi guys,
I want to make a game for Nokia phones is java possible to make games for Nokia? Please guys if u know it tell me?
Thank u
|
|
|
|
|
Take a look here[^] for some suggestions.
|
|
|
|
|
Clever! Who would of thought to search Google...
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Nagy Vilmos wrote: Clever! Who would of thought to search Google...
Fewer than 10% of new posters here
|
|
|
|
|
Richard MacCutchan wrote: Fewer than 10% of new posters here
ftfy
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
public class RunThread
{
public static void main(String[] args) throws InterruptedException
{
TwoThread tt = new TwoThread();
tt.start();
for(int i = 0;i<25;i++)
{
System.out.println("Main Thread");
}
}
}
class TwoThread extends Thread
{
public void run()
{
for(int i=0;i<25;i++)
System.out.println("New Thread");
}
}
The output of this program is always "Main Thread" displayed 25 times followed by "New Thread" 25 times. Can someone explain why this sequence is always followed? Even though a thread is already spawned, why does the main function always get executed before the new thread?
|
|
|
|
|
Since you included run in your second thread then you need to invoke that method not start so you have to change the tt.start() to tt.run()
|
|
|
|
|
When several threads are ready (i.e. not waiting on something), the Windows kernel will select one thread (actually one thread for each available core) and run it; it relies on process priority, thread priorities and historic information to decide which one(s). And it will typically reconsider only at specific points in time (some 60 times per second). As soon as a thread becomes ready or a running thread is no longer ready (e.g. it blocks on a WaitOne), it will reconsider.
Your code not having any thread synchronization leaves full freedom to the kernel, which applies a specific algorithm, so don't expect random behavior for short-lived threads.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
Be forewarned: this is a difficult question; folks on StackOverflow, Eclipse forums, Sun forums, and ComEclipse support, and others have been stumped by it. If you can answer this, you're a certified programming god.
---
How can I create an SWT Variant object that contains a float array?
Since SWT's Variant type doesn't support this out of the box, here's my attempt to make this work:
public static Variant CreateVariantForArray(float[] array)
{
if(array == null){
return null;
}
short FADF_FIXEDSIZE = 0x10;
short FADF_HAVEVARTYPE = 0x80;
short fFeatures = (short) (FADF_FIXEDSIZE | FADF_HAVEVARTYPE);
int elementSize = 4;
int pvData = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT,
4 * array.length);
OS.MoveMemory(pvData, array, 4 * array.length);
int sizeofSafeArray = 12 + 4 + 1 * 8;
int pSafeArray = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT,
sizeofSafeArray);
int offset = 0;
OS.MoveMemory(pSafeArray + offset, new short[] { 1 }, 2);
offset += 2;
OS.MoveMemory(pSafeArray + offset, new short[] { fFeatures }, 2);
offset += 2;
OS.MoveMemory(pSafeArray + offset, new int[] { elementSize }, 4);
offset += 4;
OS.MoveMemory(pSafeArray + offset, new int[] { 0 }, 4);
offset += 4;
OS.MoveMemory(pSafeArray + offset, new int[] { pvData }, 4);
offset += 4;
OS.MoveMemory(pSafeArray + offset, new int[] { array.length }, 4);
offset += 4;
OS.MoveMemory(pSafeArray + offset, new int[] { 0 }, 4);
offset += 4;
int pVariant = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
short vt = (short) (OLE.VT_ARRAY | OLE.VT_R4);
OS.MoveMemory(pVariant, new short[] { vt }, 2);
OS.MoveMemory(pVariant + 8, new int[] { pSafeArray }, 4);
return new Variant(pVariant, OLE.VT_VARIANT);
}
It doesn't work. Any idea why? Or better yet, got any code that takes a float[] and gives back a Variant?
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon
Judah Himango
|
|
|
|