smi256
|
|
« Reply #30 on: October 19, 2005, 10:15:23 PM » |
|
Adv. C HW (Due the first of Nov. Expect more HW on the 25th)
1) Print the contents of a link list in reverse order
2) Research how link lists are useful in text editors (concepts, not code)
3) Use link lists to add and multiply (fourth order) polynomials a) Both polynomials should have all of its orders b) One polynomial should have all of its orders
I wonder if anyone reads this? :hmmm:
|
|
|
Logged
|
*was here
|
|
|
SS
|
|
« Reply #31 on: October 20, 2005, 01:17:34 PM » |
|
I read it! ( link lists are the same as linked lists, right?)
|
|
|
Logged
|
Peter 'SpectralShadows' Boughton, Seeker of Perfection, BPsite Sitelord.
Till shade is gone, till water is gone, into the Shadow with teeth bared, screaming defiance with the last breath, to spit in the Sightblinder's eye on the Last Day.
|
|
|
smi256
|
|
« Reply #32 on: October 20, 2005, 08:01:42 PM » |
|
link list==linked list ? printf("I thought so") : printf(" oops :blink: my bad");
mayeb I should work on and finish that Knight's Tour problem.... I don't know how to make it GUI though, I could just as well do it in the MS-DOS window...in which case I'd just do it in C!! or just print the movements A1, B3 sort of thing...
|
|
« Last Edit: October 20, 2005, 08:02:56 PM by smi256 »
|
Logged
|
*was here
|
|
|
smi256
|
|
« Reply #33 on: November 01, 2005, 02:05:38 AM » |
|
Oh YES! *CHARGING* CLEAR!! *ZAP* :sheep: Well… not really, but seeing that my code takes 6 pages 8 pages (+2 for screenshots) (I couldn't fit as many lines as I thought on one page)[/size] to print it would have been a big post. However, I did find the Export option on my compiler, so I exported it to html and added a little bit to it (my screen shots). Oh right, what the hell is the assignment? The assignment was to: Add two full fourth order polynomials (I’m saying “full polynomial”, I just mean that there are no gaps in the polynomial powers, ex 1x^4 + 1x^3 + 1x^2 + 1x^1) Multiply two full fourth order polynomials Add one full and one NOT full polynomial Multiply one full and on NOT full polynomial Oh ya, did I mention that this is to be done ALL with linked lists? No? Well, they are! Here it is. Project Polynomial IndexCould some please tell me why I’m getting those errors. :unsure:
|
|
« Last Edit: November 02, 2005, 02:14:12 AM by smi256 »
|
Logged
|
*was here
|
|
|
Mr.Slippery
|
|
« Reply #34 on: November 02, 2005, 08:36:45 AM » |
|
Oh YES! *CHARGING* CLEAR!! *ZAP* :sheep: Well… not really, but seeing that my code takes 6 pages 8 pages (+2 for screenshots) (I couldn't fit as many lines as I thought on one page)[/size] to print it would have been a big post. However, I did find the Export option on my compiler, so I exported it to html and added a little bit to it (my screen shots). Oh right, what the hell is the assignment? The assignment was to: Add two full fourth order polynomials (I’m saying “full polynomial”, I just mean that there are no gaps in the polynomial powers, ex 1x^4 + 1x^3 + 1x^2 + 1x^1) Multiply two full fourth order polynomials Add one full and one NOT full polynomial Multiply one full and on NOT full polynomial Oh ya, did I mention that this is to be done ALL with linked lists? No? Well, they are! Here it is. Project Polynomial IndexCould some please tell me why I’m getting those errors. :unsure: Your next assignment is to integrate the Zero Wing game graphics into your Java program for teaching Multiplication to children: "MAIN SCREEN TURN ON" What is the answer to 6 x 7 ? [ummm, 67?] WRONG!! ANSWER!! <YOU KNOW WHAT YOU DOING??> Try again: What is 6 x 7? [uhh, 76?] WRONG AGAIN!! <YOU HAVE NO CHANCE TO SURVIVE MAKE YOUR TIME> and so on... --Slip :alien:
|
|
|
Logged
|
|
|
|
smi256
|
|
« Reply #35 on: November 03, 2005, 10:25:59 PM » |
|
I'm glad you like that Slip Things I should add to my polynomial program: - De-allocate my linked lists at the end of the program:
- From the main: poly1, poly2, sum, prod…
[li]From other functions free up set individual links to NULL at the end of the function: current, preS, preC, slot…
[li]Add special cases to the print function:- If the coefficient is zero, then don’t print that term
[li]If the power is zero, then only print the coefficient [li]If the power is one, then print the coefficient and the variable
|
|
« Last Edit: November 06, 2005, 08:45:02 PM by smi256 »
|
Logged
|
*was here
|
|
|
Mr.Slippery
|
|
« Reply #36 on: November 04, 2005, 03:27:13 AM » |
|
I'm glad you like that Slip What i'd really like is for you to find a way to make your AYBABTU animation run only once, then hold at a specifc graphic image. think u can do it? (fortunately, my Firefox setup can disable animated graphics, but... whew! eyestrain.) -Slip :alien:
|
|
|
Logged
|
|
|
|
smi256
|
|
« Reply #37 on: November 04, 2005, 07:01:26 AM » |
|
I didn't make the image...I stole it. I don't know how to make animated gif files...mostly because I’ve never really cared to find out
|
|
|
Logged
|
*was here
|
|
|
snowinferno
|
|
« Reply #38 on: November 06, 2005, 12:11:05 PM » |
|
Could some please tell me why I’m getting those errors. :unsure: I think in your POLY struct if you change struct POLY * next; to POLY * next; it will get rid of a bunch of those errors warnings... if that causes it to not even run, then look through configuration/preferences and turn the warning level down. It seems to think that a "struct POLY*" is incompatible with "POLY *" :blink: .
|
|
« Last Edit: November 06, 2005, 12:13:11 PM by snowinferno »
|
Logged
|
|
|
|
snowinferno
|
|
« Reply #39 on: November 06, 2005, 12:44:30 PM » |
|
Things I should add to my polynomial program: - De-allocate my linked lists at the end of the program:
- From the main: poly1, poly2, sum, prod…
[li]From other functions free up individual links at the end of the function: current, preS, preC, slot…
I should have put this in the other post but its late, and i've been working on java homework you really don't want to free the individual links... *gets out a soapbox, steps up and begins a speach* since you dont copy the contents of the struct around, freeing up your current, preS, preC, etc... at the end of those functions will "inadvertently" free up the node in your linked list, then if you go and try to free up your list, you'll get heap overflow... returning more memory than you were allocated. The best option for your other functions is to set the current, preS, preC, etc... pointers null as the last thing you do in the function. *takes a bow, picks up the soapbox and puts it away* :ph34r:
|
|
« Last Edit: November 06, 2005, 12:45:21 PM by snowinferno »
|
Logged
|
|
|
|
smi256
|
|
« Reply #40 on: November 06, 2005, 09:03:10 PM » |
|
Thanks snowinferno! In java I haven’t read about “throws Exception” stuff yet. But what I have done is found a few little ways around the whole situation One, if you have a known list of options, only let those options be chosen: public static Object showInputDialog ( Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue ) JOptionPane.showInputDialog(null,"Message","Title",3,null,inputOptions,null); Note: this doesn’t work with switch, use a large if, else if, else if block When asking the user to input a number: public boolean stringIsDigits(String input) { boolean result=true; char test[] = input.toCharArray(); for(int i=0; i<test.length; i++) { if(result==true) { result=Character.isDigit(test); } } return (result); }//end stringIsLettersOrDigits
|
|
|
Logged
|
*was here
|
|
|
smi256
|
|
« Reply #41 on: November 07, 2005, 07:12:24 AM » |
|
My Part 5 for Java I really need to learn Exception Handling :rolleyes: /*********************************************** * Name: Peter Kaminsky * Course: CIS 43 Java * Assingment Number: #6 * Assingment: Getting started with OOP * Compiler: JCreator ***********************************************/ package Kaminsky.Peter.Bank; public class BankAccount //extends object { private int balance; private int totalWithdraw; private int totalDeposit; private String accountHistory; private String accountSummary; private String userName; public BankAccount() { balance = 0; totalWithdraw = 0; totalDeposit = 0; accountHistory = ""; userName = ""; } public void deposit(int amount) { balance += amount; totalDeposit += amount; accountHistory += String.format("deposit %,7dn",amount); } public void withdraw(int amount) { balance -= amount; totalWithdraw -= amount; accountHistory += String.format("withdraw %,7dn",amount); } public void setUserName(String name) { userName=name; } public int getBalance() { return balance; } public int getTotalWithdraw() { return totalWithdraw; } public int getTotalDeposit() { return totalDeposit; } public String getAccountHistory() { return accountHistory; } public String getAccountSummary() { accountSummary = String.format("Deposits %,7dn",totalDeposit); accountSummary += String.format("Withdrawals %,7dn",totalWithdraw); accountSummary += String.format("......................n"); accountSummary += String.format("Balance $%,7d",balance); return accountSummary; } public String getUserName() { return userName; } } /*********************************************** * Name: Peter Kaminsky * Course: CIS 43 Java * Assingment Number: #6 * Assingment: Getting started with OOP * Compiler: JCreator ***********************************************/ import Kaminsky.Peter.Bank.BankAccount; import Kaminsky.Peter.Check.Strings; import javax.swing.JOptionPane; import javax.swing.JTextArea; import java.awt.Font; import java.awt.Color; //import java.lang.Character; //import java.lang.String; public class UseBankAccount { public static void main (String[] args) { Strings check = new Strings(); BankAccount account = new BankAccount(); JTextArea outputArea = new JTextArea(); outputArea.setFont(new Font("Courier New", Font.BOLD, 13)); outputArea.setBackground(null); String inputS, message; int inputI=0; Object answer; String inputOptions[] = {"Deposit", "Withdraw", "Account History", "Account Summery", "New Account", "Exit"}; //public static Object showInputDialog (Component parentComponent, // Object message, // String title, // int messageType, // Icon icon, // Object[] selectionValues, // Object initialSelectionValue) // throws HeadlessException //Page 515 //PLAIN_MESSAGE = -1 //ERROR_MESSAGE = 0 //INFORMATION_MESSAGE = 1 //WARNING_MESSAGE = 2 //QUESTION_MESSAGE = 3 do { account.setUserName(JOptionPane.showInputDialog(null, "What is your name?","New Account",3)); }while(account.getUserName()==null); do { message = String.format("Welcome %s!n", account.getUserName()); message += String.format("Your Balance: $%,dnn", account.getBalance()); message += "Please make a selection:"; answer = JOptionPane.showInputDialog(null, message, "Bank-O-Pete", 3, null, inputOptions, null); if(answer == "Deposit") { //System.out.println("Deposit"); do { do { inputS = JOptionPane.showInputDialog(null, "How much is to be deposited?", "Deposit",3); }while(check.stringIsDigits(inputS)==false); inputI=Integer.parseInt(inputS); }while(inputI<0); message = String.format("Deposited: $%,d",inputI); JOptionPane.showMessageDialog(null, message, "Deposit", -1); account.deposit(inputI); } else if(answer == "Withdraw") {// System.out.println("Withdraw"); do { do { inputS = JOptionPane.showInputDialog(null, "How much to withdrawal?", "Withdraw",3); }while(check.stringIsDigits(inputS)==false); inputI=Integer.parseInt(inputS); }while(inputI<0); if(inputI>account.getBalance()) { message = "I'm sorry. You can't take more then what you have.nn"; message += String.format("You'r withdrawal $%,dn",inputI); message += String.format("Balance $%,dn",account.getBalance()); JOptionPane.showMessageDialog(null, message, "Withdraw", -1); } else { message = String.format("Withdrawal: $%,d",inputI); JOptionPane.showMessageDialog(null, message, "Withdraw", -1); account.withdraw(inputI); } } else if(answer == "Account History") { //System.out.println("Account History"); message = account.getAccountHistory(); message += "n______________________n"; message += account.getAccountSummary(); outputArea.setText(message); JOptionPane.showMessageDialog(null, outputArea, "Account History", -1); } else if(answer == "Account Summery") { //System.out.println("Account Summery"); message = account.getUserName() + "'s Account Summery"; outputArea.setText(account.getAccountSummary()); JOptionPane.showMessageDialog(null, outputArea, message, -1); //System.out.println(account.getAccountSummary()); } else if(answer == "New Account") { //System.out.println("New Account"); //public static int showConfirmDialog (Component parentComponent, // Object message, // String title, // int optionType, // int messageType) inputI = JOptionPane.showConfirmDialog(null, "Are you sure you want to make a new Account?", "Confirm New Account", 0, 2); //System.out.println(inputI); if(inputI==0) { account = new BankAccount(); do { account.setUserName(JOptionPane.showInputDialog(null, "What is your name?","New Account",3)); }while(account.getUserName()==null); } } else if(answer == "Exit") { //System.out.println("Exit"); inputI = JOptionPane.showConfirmDialog(null, "Are you sure you want to Exit?", "Confirm Exit", 0, 2); if(inputI!=0) answer = ""; } }while(answer != "Exit"); }//end main }//end class UseBankAccount package Kaminsky.Peter.Check;
public class Strings { public boolean stringIsLetters(String input) { boolean result=true; char test[] = input.toCharArray(); for(int i=0; i<test.length; i++) { if(result==true) { result=Character.isLetter(test); } } return (result); }//end stringIsLettersOrDigits public boolean stringIsDigits(String input) { boolean result=true; char test[] = input.toCharArray(); for(int i=0; i<test.length; i++) { if(result==true) { result=Character.isDigit(test); } } return (result); }//end stringIsLettersOrDigits }
|
|
|
Logged
|
*was here
|
|
|
smi256
|
|
« Reply #42 on: November 07, 2005, 07:15:22 AM » |
|
I can not edit my post [correction] that last file is named Strings.java
|
|
|
Logged
|
*was here
|
|
|
Guest:blackmail
Guest
|
|
« Reply #43 on: November 08, 2005, 11:10:15 PM » |
|
O o. A lot of new things happened on the Forum. Gggggggggggggggggrrrrrrrrrrrrrrrr. I needed to know it before.
|
|
|
Logged
|
|
|
|
smi256
|
|
« Reply #44 on: November 09, 2005, 08:37:13 AM » |
|
I told you!! Didn't I tell you?? Well I did. You have untill tomorrow afternoon to get it done. remember, you don't have to make it GUI. PS. normaly people who have an account, login then post :rolleyes:
|
|
« Last Edit: November 09, 2005, 08:38:51 AM by smi256 »
|
Logged
|
*was here
|
|
|
|