Computer Science

Hobart College

By

Monday, 30 March 2015

Today we looked at an example of data representation based on the last question of Binary Worksheet 6 that involved indexed colours, and then played spot the mistake with a couple of algorithm examples… Algorithms – Spot the mistakes.

The rest of the lesson was given over to test revision and finishing off any of the overdue worksheets.

By

Friday, 27 March 15

Today we finished off the group “text manipulation” projects.

If you’re left feeling a bit confused (or maybe in a state of shock and awe!) then I’d recommend working through the option Prac 5 in your own time, but not at the expense of finishing…

Binary Worksheet 6 – this was due today! If you haven’t handed it in, then at the very least get as much of it in by Monday as you possibly can! That way I can mark it and get it back to you prior to…

End of Term Test – this will be on Wednesday of next week, and will include everything we’ve done with Algorithms and Binary.

By

Wednesday, 25 March 2015

Today we looked at how to construct an algorithm for situation that requires a loop, and in particular the example of how we might reverse the characters of a text string.

I thought it might be handy to provide an example of what the algorithm we came up with would like in code, so here it is….  I’ll hand out a hard copy next lesson so you’ve got it for reference.

 

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

/*
 * A simple text manipulation example.
 * Features a custom method that reverses a text string.
 * Rob Torok, 25/3/15
 */

public class Reverse extends Applet implements ActionListener
{
    Label instructionLabel;
    TextField inputText;
    Button reverseButton;
    String inString, outString;
    
    public void init()
    {
        inString = "";
        outString = "";
        
        instructionLabel = new Label("Please enter some text: ");
        inputText = new TextField(20);
        reverseButton = new Button("Reverse");
        
        setSize(300,200);
        add(instructionLabel);
        add(inputText);
        add(reverseButton);

        reverseButton.addActionListener(this);
    }
    
    public void paint(Graphics g)
    {
        g.drawString("Reversed text: "+ outString,20,100);
        System.out.println(outString);
    }
    
    public void actionPerformed(ActionEvent e)
    {
        inString = inputText.getText();
        outString = reverseText(inString);
        repaint();    
    }
    
    public String reverseText(String input)
    {
        String output = "";
        
        for (int index=input.length()-1;index>=0;index--)
        {
            output = output + input.charAt(index);
        }
        
        return output;
    }
}

By

Monday, 23 March 2015

Today we reviewed some weird stuff that happens with 2’s complement arithmetic when there aren’t enough bits, and started an open-ended “text manipulation” task.

The idea was to design the User Interface for an applet that will manipulate text in some interesting way, for example:

  • Change the case of the input depending on the option selected by the user (e.g. Sentence case, ALL CAPS, lower case, Title Case)
  • Code/decode a message (e.g. using a Caesar cipher)
  • Find/replace text
  • Reverse a text string
  • Rearrange and format a name (e.g. “john SMITH”, becomes “Smith, John”).

We spent the rest of the class creating an algorithm for one of these that will be used by another team to implement it.

We also handed out Binary Worksheet 6 and agreed on a date for the end of term test… next Wed 1 April. The test will cover binary and algorithms.

 

By

Friday, 20 March 2015

Today was very much a catch up day, providing help to those who needed it with the recent worksheets, finishing off Prac 4, and marking the recent pracs.

By

While Rob is away…. (again!)

I’m really sorry to be away even more that I was expecting this time last week, but there aren’t any more reasons for me to be away that I’m aware of after this week – and in any event, I know you’re in safe hands with Andrew!

I’ve uploaded the next couple of worksheets (Binary 6 and Data Types 1 & 2), but it will depend on where you’re up to and what Andrew wants to do with you.

See you on Friday!

By

Wednesday, 11 March 2015

Today we handed back and reviewed the recent wave of worksheets, reviewed two’s complement and hex conversion, and marked some pracs.

I also handed out Binary Worksheet 5 – Floating point

While I’m away on Friday…

  • Finish “Binary Worksheet 5 – Floating point”
  • Start “Prac 4 – Components and Events”

By

Friday, 6 March 2015

Today we finished off our introduction to floating point representation, finishing off the examples on page 13 of the “Computer Representation of Numbers” booklet.

We also made a start on Prac 3 – Integers and reals

By

Wednesday, 4 March 2015

Today we had a look at how real numbers, including very large and very small numbers, are stored using a floating point representation.

Skip to toolbar