Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • SuperNativeZ: 2009SCAPE - Perfect Realistic Emulation. Play Runescape like it was in 2009. [link]
      February 18, 2020, 01:04:45 PM
    • SuperNativeZ: 2009SCAPE - Perfect Realistic Emulation. Play Runescape like it was in 2009. [link]
      February 18, 2020, 01:04:39 PM
    • SuperNativeZ: 2009SCAPE - Perfect Realistic Emulation. Play Runescape like it was in 2009. [link]
      February 18, 2020, 01:04:35 PM
    • ragnoroker: Join RuneGuild Today! BIG DROP PARTY IN 1 HOUR JOIN NOW - Newish Server 30+ Online all the time - Very Unique - Play now : [link]
      February 15, 2020, 04:16:38 PM
    • ragnoroker: Join RuneGuild Today! BIG DROP PARTY IN 1 HOUR JOIN NOW - Discord : [link]
      February 15, 2020, 04:15:41 PM
    • ragnoroker: Join RuneGuild Today! BIG DROP PARTY IN 1 HOUR JOIN NOW :) - [link]
      February 15, 2020, 04:14:50 PM
    • friendlyhelper: Meet up with old and new friends and explore what Runescape Classic could have been had development continued [link]
      February 15, 2020, 03:55:17 PM
    • friendlyhelper: Meet up with old and new friends and explore what Runescape Classic could have been had development continued [link]
      February 15, 2020, 03:49:34 PM
    • friendlyhelper: After well over 6 years of continuous runtime, RSCR still most actively developed RSC server  [link]
      February 15, 2020, 03:49:29 PM
    • SnowRSPS: Checkout Snowrsps.com - Snow317.org - Snowscape.net Open 24.7 [link] !Do not join Galaxy!
      February 15, 2020, 08:15:39 AM
    • SnowRSPS: Checkout Snowrsps.com - Snow317.org - Snowscape.net Open 24.7 [link] !Do not join Galaxy!
      February 15, 2020, 08:15:32 AM
    • SuperNativeZ: GALAXY #1 UNIQUE CUSTOM RSPS [link][link]
      February 14, 2020, 12:27:16 PM
    • SuperNativeZ: GALAXY #1 UNIQUE CUSTOM RSPS [link][link]
      February 14, 2020, 12:27:11 PM
    • SuperNativeZ: GALAXY #1 UNIQUE CUSTOM RSPS [link][link]
      February 14, 2020, 12:27:00 PM
    • ragnoroker: Looking for a new server? Join RuneGuild : [link] You won't be disappointed.
      February 14, 2020, 07:49:42 AM
    • ragnoroker: Looking for a new server? Join RuneGuild : [link] You won't be disappointed.
      February 14, 2020, 07:49:37 AM
    • ragnoroker: Looking for a new server? Join RuneGuild : [link] You won't be disappointed.
      February 14, 2020, 07:49:33 AM
    • Tonystark2830: https: //discord .gg /AHeVSMQ
      February 13, 2020, 11:35:21 AM
    • Tonystark2830:[link]
      February 13, 2020, 11:35:06 AM
    • Tonystark2830:[link] who ever has the most invites will be given money weekly! whats the catch? you must have over 15 invites for the week!  if you are tied with someone else at the end of the week you will both be awarded the same amount "no it will not be split"
      February 13, 2020, 11:34:42 AM

    Show Posts

    This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


    Topics - z

    Pages: [1]
    1
    Code: Java
    1. importjava.util.Iterator;
    2. importjava.util.LinkedList;
    3. importjava.util.Queue;
    4. importjava.util.Scanner;
    5. importjava.util.function.DoubleUnaryOperator;
    6. importjava.util.function.DoubleBinaryOperator;
    7. importjava.util.stream.Collectors;
    8.  
    9. /**
    10.  * calc - a prefix notation calculator
    11.  */
    12. publicclass calc {
    13.     public calc(){
    14.         Scanner scanner =new Scanner(System.in);
    15.         while(true){
    16.             System.out.print("> ");
    17.             String expr = scanner.nextLine();
    18.             if(expr.equals("quit"))break;
    19.             if(expr.equals("help")|| expr.equals("?"))
    20.                 usage();
    21.             Queue<String> q =new LinkedList<>();
    22.             Scanner exprScanner =new Scanner(expr);
    23.             while(exprScanner.hasNext())
    24.                 q.add(exprScanner.next());
    25.             System.out.println("Tokens: "+ q);
    26.             try{
    27.                 Expression res = parse(q);
    28.                 System.out.println("In-fix: "+ res);
    29.                 System.out.println(res.eval());
    30.             }catch(Exception e){
    31.                 System.err.println("Error: "+ e.getMessage());
    32.             }
    33.         }
    34.     }
    35.  
    36.     private Expression parse(Queue<String> q)throwsException{
    37.         if(q.isEmpty())thrownewException("Invalid input.");
    38.         String token = q.remove().replace(")","");
    39.         try{
    40.             returnnewNumber(Double.parseDouble(token));
    41.         }catch(NumberFormatException nfe){
    42.             switch(token){
    43.                 case"(sqrt":returnnew SquareRoot(parse(q));
    44.                 case"(+":returnnew Add(parse(q), parse(q));
    45.                 case"(*":returnnew Multiply(parse(q), parse(q));
    46.                 case"(/":returnnew Divide(parse(q), parse(q));
    47.                 case"(-":
    48.                     if(q.peek().contains(")"))
    49.                         returnnew Negate(parse(q));
    50.                     else
    51.                         returnnew Subtract(parse(q), parse(q));
    52.             }
    53.         }
    54.         thrownewException("Invalid input.");
    55.     }
    56.  
    57.     publicstaticvoid main(String[] args)throwsException{
    58.         try{
    59.             new calc();
    60.         }catch(Exception e){
    61.             System.exit(1);
    62.         }
    63.     }
    64.  
    65.     privatestaticvoid usage(){
    66.         System.out.println("calc - a prefix notation calculator");
    67.         System.out.println("Enter an expression below to be evaluated.");
    68.     }
    69.  
    70.     publicinterface Expression {
    71.         publicdouble eval();
    72.         publicString toString();
    73.     }
    74.  
    75.     staticclassNumberimplements Expression {
    76.         double val;
    77.  
    78.         Number(double val){
    79.             this.val= val;
    80.         }
    81.  
    82.         publicdouble eval(){
    83.             return val;
    84.         }
    85.  
    86.         publicString toString(){
    87.             return""+val;
    88.         }
    89.     }
    90.  
    91.     staticclass UnaryExpression implements Expression {
    92.         privateString operator;
    93.         privatedouble defaultValue;
    94.         private DoubleUnaryOperator op;
    95.         private Expression expression;
    96.  
    97.         UnaryExpression(String operator, double defaultValue,
    98.                         DoubleUnaryOperator op, Expression expression){
    99.             this.operator= operator;
    100.             this.defaultValue= defaultValue;
    101.             this.op= op;
    102.             this.expression= expression;
    103.         }
    104.  
    105.         publicdouble eval(){
    106.             return op.applyAsDouble(expression.eval());
    107.         }
    108.  
    109.         publicString toString(){
    110.             return operator +"("+ expression.toString()+")";
    111.         }
    112.     }
    113.  
    114.     staticclass BinaryExpression implements Expression {
    115.         privateString operator;
    116.         privatedouble defaultValue;
    117.         private DoubleBinaryOperator op;
    118.         private Queue<Expression> expressions;
    119.  
    120.         BinaryExpression(String operator, double defaultValue,
    121.                          DoubleBinaryOperator op, Expression[] expressions){
    122.             this.operator= operator;
    123.             this.defaultValue= defaultValue;
    124.             this.op= op;
    125.             this.expressions=new LinkedList<Expression>();
    126.             for(Expression expression : expressions)
    127.                 this.expressions.add(expression);
    128.         }
    129.  
    130.         publicdouble eval(){
    131.             return expressions.stream()
    132.                               .mapToDouble(Expression::eval)
    133.                               .reduce(op)
    134.                               .orElse(defaultValue);
    135.         }
    136.  
    137.         publicString toString(){
    138.             return expressions.stream()
    139.                               .map(Object::toString)
    140.                               .collect(Collectors.joining(" "+ operator +" ", "(", ")"));
    141.         }
    142.     }
    143.  
    144.     staticclass Negate extends UnaryExpression {
    145.         Negate(Expression expression){
    146.             super("-", 0.0, (v)->-v, expression);
    147.         }
    148.     }
    149.  
    150.     staticclass SquareRoot extends UnaryExpression {
    151.         SquareRoot(Expression expression){
    152.             super("?", 0.0, (v)->Math.sqrt(v), expression);
    153.         }
    154.     }
    155.  
    156.     staticclass Add extends BinaryExpression {
    157.         Add(Expression... expressions){
    158.             super("+", 0.0, (l, r)-> l + r, expressions);
    159.         }
    160.     }
    161.  
    162.     staticclass Subtract extends BinaryExpression {
    163.         Subtract(Expression... expressions){
    164.             super("-", 0.0, (l, r)-> l - r, expressions);
    165.         }
    166.     }
    167.  
    168.     staticclass Multiply extends BinaryExpression {
    169.         Multiply(Expression... expressions){
    170.             super("*", 0.0, (l, r)-> l * r, expressions);
    171.         }
    172.     }
    173.  
    174.     staticclass Divide extends BinaryExpression {
    175.         Divide(Expression... expressions){
    176.             super("/", 0.0, (l, r)-> l / r, expressions);
    177.         }
    178.     }
    179. }

    What works: (- 2 2), (- 2), (+ 2 2), (+ (+ 2 2) (+ 2 2))

    What doesn't work: (+ 2 2 2 2), (- (+ 2 2))

    I suck at parsing this stuff properly. Any suggestions?

    4
    Off-Topic (Spam) / post your biggest stack traces, boys
    « on: December 17, 2015, 03:53:17 PM »
    java.io.FileNotFoundException: 2.txt (The system cannot find the file specified)
            at java.io.FileInputStream.open0(Native Method)
            at java.io.FileInputStream.open(Unknown Source)
            at java.io.FileInputStream.<init>(Unknown Source)
            at java.util.Scanner.<init>(Unknown Source)
            at Model.LittleChessModel.newGame(LittleChessModel.java:138)
            at GUI.LittleChessGUI.lambda$start$0(LittleChessGUI.java:118)
            at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
            at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
            at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
            at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
            at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
            at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
            at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
            at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
            at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
            at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
            at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
            at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
            at javafx.event.Event.fireEvent(Unknown Source)
            at javafx.scene.Node.fireEvent(Unknown Source)
            at javafx.scene.control.Button.fire(Unknown Source)
            at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source)
            at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
            at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
            at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
            at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
            at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
            at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
            at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
            at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
            at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
            at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
            at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
            at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
            at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
            at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
            at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
            at javafx.event.Event.fireEvent(Unknown Source)
            at javafx.scene.Scene$MouseHandler.process(Unknown Source)
            at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
            at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
            at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
            at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
            at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(Unknown Source)
            at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
            at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
            at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
            at com.sun.glass.ui.View.notifyMouse(Unknown Source)
            at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
            at com.sun.glass.ui.win.WinApplication.lambda$null$148(Unknown Source)
            at java.lang.Thread.run(Unknown Source)

    5
    Off-Topic (Spam) / Did someone say...
    « on: December 15, 2015, 07:32:19 AM »

    6
    Music / Watch these
    « on: December 06, 2015, 05:18:50 PM »



    7
    Java Programming / Feedback plz
    « on: November 21, 2015, 06:21:56 PM »

    8
    General Programming / What the fudge
    « on: December 01, 2014, 04:12:11 PM »
    Code: C++
    1. #include <iostream>
    2.  
    3. int main(void){
    4.     std::cout<<"Hello World"<< std::endl;
    5.     returnEXIT_SUCCESS;
    6. }

    with

    g++ -S test.cpp

    produces http://pastebin.com/raw.php?i=UmbPWFAF

    on my Macbook Pro (OS X Yosemite)

    9
    Quote from: eBay
    Here you have an opportunity to buy access to nice icq number.

    Many people like nice phone numbers car numbers or street addresses.
    In icq you have same situation: there are ugly icq numbers and pretty icq numbers.
    Here You have an opportunity to buy access to nice icq uin (number) that was never used!

    History of the uins.

    These uins were registered and then abandoned by users (years 1997-1999).
    So, after very long period without use (6-7 years!), these uins became invisible (this happened with many many unused icq numbers).
    Currently you can't find them in icq search. Invisibility of number in almost all cases means that this number is totally clean and nobody cares about them, they are just empty slots in system.
    So, getting such number is same as registering new one, but short and nice as you want or as you can allow to yourself  :-)

    What you should do after you buy number.

    Log into your number on site.
    Your number has invisible state - you can't find yourself in search.

    At this stage you also can not change the password.
    After moment that you fill any info in your profile and hit apply button,
    number will become visible - you will be able to find yourself in icq search and you will be able to change password.
    After number became visible it's impossible to return it to invisible state.
    You will HAVE to attach some email address to uin in order retrieve your password in case you lose it.
    For example, if your number is 66-666-661, then create email account [email protected] and attach it to your number.

    How to attach email?

    You go to icq.com - > support -> attach email.

    How to change your password?
     
    You go to icq.com - > support -> change password.


    Don't give your password to anyone.
    Don't log into suspicious sites with your icq number.
    Always use trusted clients to connect.
    Best client is one from official site icq.com.


    MY ADVICES TO POTENTIAL BUYER:
    0) DON'T BUY CHEAP ICQ UINS.
        EVERY NUMBER HAS ITS PRICE - NOT LESS, NOT MORE.
        AND LOW PRICED NICE NUMBER IS ALWAYS A GOOD WAY TO LOSE YOUR MONEY.
        BUY FROM SELLERS WITH GOOD HISTORY. GOOD SELLING HISTORY IS ALWAYS BIG PLUS.

    1 ) PREFERABLE TO BUY INVISIBLE UINS.
         IN OTHER WORDS - BEST NUMBERS ARE INVISIBLE NUMBERS.

    2) IF SELLER OFFERS INVISIBLE NUMBER,
        THEN YOU SHOULD CHECK THAT THIS IS TRUE AND THERE IS NO MISTAKE THERE.
    HOW TO CHECK THAT NUMBER IS OK?
    a) FIRST CHECK THAT NUMBER IS REALLY INVISIBLE, BY SEARCHING IT IN ICQ MESSENGER.
    b) IF NUMBER IS INVISIBLE, THEN GO TO icq.com/password/en AND FILL NUMBER IN FORM.
         IF YOU WILL GET MESSAGE THAT YOU CAN'T RETRIEVE PASSWORD,
         THEN NUMBER IS SAFE, NUMBER IS OK.
    c)  IN OTHER CASE (that you will not get message "CAN'T RETRIEVE PASSWORD"),
         DON'T BUY THIS NUMBER.
         WRITE MESSAGE TO SELLER, SAY HIM THAT THERE IS A MISTAKE IN HIS LISTING,
         AND IF YOU WILL NOT GET MESSAGE FROM SELLER LIKE "SORRY, IT WAS A MISTAKE",
         AND NUMBER WILL STILL ON SITE AS IT WAS BEFORE,
         THEN REPORT ITEM TO EBAY TEAM AS INAPPROPRIATE.




    Pay method: Paypal
    Only Verified PayPal payments are accepted.
    Attention!
    Your Paypal details must be the same with your eBay details.
    Otherwise your payments will not be accepted.
    http://www.ebay.com/sch/allcategories/all-categories/?_rdc=1_itemId=120889042226&_nkw=NICE+ICQ+NUMBER+6+DIGITS+INVISIBLE+UIN+TO+BUY&_trksid=p2047675.m4099.l9146

    Pages: [1]
    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal