Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
AndrewB

Minor Moral Dilemma

Recommended Posts

I've been working on this Java assignment over the weekend. It's the 5th and final (and optional) assignment for our class. Basically, we get marked on our 4 best assignments. So far, we've had three good assignments and one horrid assignment, which is the perfect state in which to do the 5th assignment.

Anyway, we've done all of the assignments in pairs. This one doesn't need to be done in pairs. For this assignment, I have done everything myself, without the aid of my regular partner. Should I include his name in my assignment anyway, and boost his marks, or should I remain honest and submit it with only my name?

Yeah, and the final exam is tomorrow morning at 8AM (about 11 hours from now.) It's basically the Cyberdemon of exams this year, and will make or break the future of quite a few people.

Share this post


Link to post

Why not ask him how he's coming along on his assignment?

This way you can also ensure that he knows he's in your debt, should he have actually been slacking.

Share this post


Link to post

No, he hasn't actually worked on the assignment. It's due first thing tomorrow. Because it's optional, he didn't do it. We have exactly the same assignment marks so far:

A1 (Inheretance and Polymorphism): 83%
A2 (Arrays): 73%
A3 (GUI and Data Structures): Unknown, probably around 15%.
A4 (File I/O, GUI, Data Structures): Unknown, probably around 80%.
A5 (Threads, Exceptions, GUI)

Share this post


Link to post

uh... yeah unless he's a really good friend (or someone who you know will return the favor in the future) don't put his name on it if he didn't do any work for it... unless it gives you a warm fuzzy feeling to give someone a grade they don't deserve

Share this post


Link to post

Thank you for the correction. (No, there is no sarcasm. I like opportunities to improve my spelling.)

Share this post


Link to post

If its an optional assignment, I'd definately leave his name off it.

Share this post


Link to post

I would have left it off too, seeing might as well not put his name on something he didn't (or can't) do, won't help him much in his future. :D Though neither would leaving it out, but, could make him realize to work harder to succeed. :D

Aye, I am not speaking much sense. :D

Share this post


Link to post
MaximusNukeage said:

you shouldn't get credit for work you didnt do

AndyB said:

For this assignment, I have done everything myself, without the aid of my regular partner.


Sounds to me like he did all the work...

Share this post


Link to post
Linguica said:

Of course not, if he didn't do any work why the hell would you put his name on it?


Yeah, and it was optional anyway, so it won't matter.

Share this post


Link to post

you know, i was thinking of learning some java after I'm finished learning C++, but I wasn't sure if I wanted to. What are some benefits of it? All I know is that it is all OOP. I was thinking of learning java to do scripting in games, but are there better languages for that? I think PHP? Give me some advice AndrewB.

thanks.

Share this post


Link to post
BBG said:

Yeah, and it was optional anyway, so it won't matter.

Well, it would have likely significantly raised his assignment mark, as it would mine. That's worth 20%.

Share this post


Link to post
Skeletor said:

I was thinking of learning java to do scripting in games, but are there better languages for that?

Use ruby

Share this post


Link to post
Skeletor said:

you know, i was thinking of learning some java after I'm finished learning C++, but I wasn't sure if I wanted to. What are some benefits of it? All I know is that it is all OOP. I was thinking of learning java to do scripting in games, but are there better languages for that? I think PHP? Give me some advice AndrewB.

thanks.

Benefits of Java are cross-O/S compatibility, easy memory management (no pointers or manual garbage collection), and a secure environment (you rarely have to worry about corrupting the file system).

The drawback of Java is that it's slower.

Share this post


Link to post

Oh yeah. Here's the dumb little program that I wrote:

import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;

/**
 *
 * <p>Title: Elevator Simulation</p>
 * <p>Description: COSC190 Assignment 5</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: SIAST -- CST</p>
 * @author Andrew Bassett (CST101)
 * @version 1.0
 */
public class ElevatorSimulation extends JFrame
        implements ActionListener
{
    /** The number of floors for the building
     * (Avoid setting this to above what your screen resolution can handle.)
     */
    private final int NUMBER_OF_FLOORS = 24;
    /** The width of the shaft (center area) of the GUI (in pixels)*/
    private final int SHAFT_WIDTH = 200;
    /** The floor where the elevator initially exists in the shaft */
    private final int INITIAL_FLOOR = 1;
    /** The width of the elevator box in pixels */
    private final int ELEVATOR_WIDTH = 30;
    /** If this is true, the elevator will fill the width of the shaft */
    private final boolean FILL_SHAFT = false;
    /** The width of the buttons in pixels */
    private final int BUTTON_WIDTH = 40;
    /** The height of the floors in pixels */
    private final int FLOOR_HEIGHT = 40;
    /** The delay (in milliseconds) between drawing updates */
    private final int DELAY = 16;

    /** The section of the GUI encompassing the information label */
    private JPanel pnlNorth = new JPanel();
    /** The section of the GUI encompassing the buttons on the left */
    private JPanel pnlWest = new JPanel(
            new GridLayout(NUMBER_OF_FLOORS, 1) );
    /** The section of the GUI encompassing the elevator shaft */
    private JComponent canvas = new JPanel(
            new GridLayout(NUMBER_OF_FLOORS, 1) );
    /** The section of the GUI encompassing the buttons on the right */
    private JPanel pnlEast = new JPanel(
            new GridLayout(NUMBER_OF_FLOORS, 1) );

    /** The thread that runs the elevator */
    private Thread threadElevator;
    /** Keeps track of whether an elevator thread is currently running */
    private boolean elevatorActive = false;

    /** The text label near the very top of the GUI */
    private JLabel lblMessage = new JLabel("", JLabel.LEFT);

    // The collection of left floor buttons
    private JButton[] leftButtons = new JButton[NUMBER_OF_FLOORS];
    // The collection of right floor buttons
    private JButton[] rightButtons = new JButton[NUMBER_OF_FLOORS];

    /** The background color of the shaft -- green if going up, red
     *  if going down
     */
    private Color currentColor = Color.green;
    /** The color of the elevator */
    private Color fixedColor = Color.yellow;

    /** Attributes affecting the position of the elevator */
    private int xPos;
    private int yPos;
    /** The floor where the elevator should currently reside */
    private int floor = INITIAL_FLOOR;

    /**
     * Constructs a new rectangle that represents the elevator
     */

    /**
     * The default constructor for the Building -- performs basic setup
     * functions and gets the GUI in working condition
     */
    public ElevatorSimulation()
    {
        // Sets the text on the title bar
        super("Elevator Simulation");

        // Sets the basic layout of the GUI to a border layout
        getContentPane().setLayout(new BorderLayout() );

        // Sets up the area of the GUI with the label information
        // (should show something like "getting passangers" or "sending
        // "passengers")
        setupNorthArea();
        // Sets up the area of the GUI with the left buttons
        setupWestArea();
        // Sets up the area of the GUI with the elevator graphics
        setupCenterArea();
        // Sets up the area of the GUI with the right buttons
        setupEastArea();

        //Adds the various components to the GUI
        getContentPane().add(pnlNorth, BorderLayout.NORTH);
        getContentPane().add(pnlWest, BorderLayout.WEST);
        getContentPane().add(canvas, BorderLayout.CENTER);
        getContentPane().add(pnlEast, BorderLayout.EAST);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        pack();
        //Sets the size of the GUI
        setSize(SHAFT_WIDTH + (BUTTON_WIDTH * 2),
                (NUMBER_OF_FLOORS * FLOOR_HEIGHT + 20) );
        //Sets the window to not be resizable
        setResizable(false);

        // Determines the position of the elevator from the left of the
        // shaft
        xPos = (canvas.getWidth() / 2) - (ELEVATOR_WIDTH / 2);

        // Determines the position of the elevator from the top of the
        // shaft
        yPos = canvas.getHeight() - ((canvas.getHeight() / NUMBER_OF_FLOORS)
                                     * (INITIAL_FLOOR) );

        canvas.setBackground(fixedColor);
        draw();
    }

    /**
     * The main execution thread of the program
     *
     * @param args
     */
    public static void main(String[] args)
    {
        ElevatorSimulation es = new ElevatorSimulation();
        es.setVisible(true);
    }

    /**
     * Sets up the area of the GUI with the label information
     * (should show something like "getting passengers" or "sending
     * passengers")
     */
    private void setupNorthArea()
    {
        lblMessage.setText("Test");
        pnlNorth.add(lblMessage);
    }

    /**
     * Sets up the area of the GUI with the left elevator buttons
     */
    private void setupWestArea()
    {
        // Creates each button on the left side of the GUI
        for (int i = NUMBER_OF_FLOORS; i > 0; i--)
        {
            JButton btn = new JButton("F" + i);
            btn.setSize(BUTTON_WIDTH, FLOOR_HEIGHT);
            leftButtons[i - 1] = btn;
            leftButtons[i - 1].addActionListener(this);
            pnlWest.add(leftButtons[i - 1]);
        }
        pnlWest.setBackground(Color.blue);
    }

    /**
     * Sets up the area of the GUI with the vertically-moving elevator
     */
    private void setupCenterArea()
    {
        for (int i = NUMBER_OF_FLOORS; i > 0; i--)
        {
            JTextField tf = new JTextField();
            tf.setBackground(fixedColor);
            tf.setEditable(false);
            tf.setBorder(new LineBorder(fixedColor, 1) );
            canvas.add(tf);
        }
    }

    /**
     * Sets up the area of the GUI with the right elevator buttons
     */
    private void setupEastArea()
    {
        // Creates each button on the right side of the GUI
        for (int i = NUMBER_OF_FLOORS; i > 0; i--)
        {
            rightButtons[i - 1] = new JButton("F" + i);
            rightButtons[i - 1].addActionListener(this);
            pnlEast.add(rightButtons[i - 1]);
        }
        pnlEast.setBackground(Color.blue);
    }

    /**
     * Performs the appropriate actions for when a button is pressed
     * @param ae
     */
    public void actionPerformed(ActionEvent ae)
    {
        Object src = ae.getSource();

        for (int i = 1; i <= NUMBER_OF_FLOORS; i++)
        {
            if (src == leftButtons[i - 1])
            {
                performLeftButton(i);
            }
            else if (src == rightButtons[i - 1])
            {
                performRightButton(i);
            }
        }
    }

    /**
     * Carries out the actions for when a left button is pressed
     *
     * @param floor the number of the button that was pressed
     */
    private void performLeftButton(int floor)
    {
        // Ensures that the elevator is not currently moving
        if (!elevatorActive)
        {
            lblMessage.setText("getting passengers");
            lblMessage.setForeground(Color.black);

            this.floor = floor;
            GotoFloor gf = new GotoFloor();
            gf.start();
        }
    }

    /**
     * Carries out the actions for when a right button is pressed
     *
     * @param floor the number of the button that was pressed
     */
    private void performRightButton(int floor)
    {
        // Ensures that the elevator is not currently moving
        if (!elevatorActive)
        {
            lblMessage.setText("sending passengers");
            lblMessage.setForeground(Color.green);

            this.floor = floor;
            GotoFloor gf = new GotoFloor();
            gf.start();
        }
    }

    /**
     * Clears the elevator from its current location
     */
    private void clear()
    {
        Graphics2D g2 = (Graphics2D)canvas.getGraphics();
        g2.setColor(fixedColor);
        g2.fillRect(FILL_SHAFT ? 0 : xPos,
                    yPos,
                    FILL_SHAFT ? canvas.getWidth() : ELEVATOR_WIDTH,
                    FLOOR_HEIGHT);
        g2.dispose();
    }

    /**
     * Draws the elevator rectangle at its current position as dictated by
     * xPos, yPos
     */
    private void draw()
    {
        Graphics2D g2 = (Graphics2D)canvas.getGraphics();
        g2.setColor(currentColor);
        g2.fillRect(FILL_SHAFT ? 0 : xPos,
                   yPos,
                   FILL_SHAFT ? canvas.getWidth() : ELEVATOR_WIDTH,
                   FLOOR_HEIGHT - 5);
        g2.dispose();
    }

    ////////////////////////////////////////////////////////////
    ///////////////// INNER CLASS gotoFloor ////////////////////
    ////////////////////////////////////////////////////////////
    class GotoFloor extends Thread
    {
        public void run()
        {
            // Declares that a thread is currently active
            elevatorActive = true;

            // Calculates the required destination pixel for the elevator
            int destPos = (canvas.getHeight() - (floor * (canvas.getHeight()
                    / NUMBER_OF_FLOORS) ) );

            // Keeps the floors within bounds
            if (floor > NUMBER_OF_FLOORS) floor = NUMBER_OF_FLOORS;
            if (floor < 1) floor = 1;

            // If the destination floor is higher
            if (yPos > destPos)
            {
                currentColor = Color.green;
                canvas.setBackground(currentColor);
                while (yPos > destPos)
                {
                    clear();
                    yPos--;
                    draw();
                    try {threadElevator.sleep(DELAY);}
                    catch (InterruptedException e) {e.printStackTrace();}
                }
            }
            // If the destination floor is lower
            else if (yPos < destPos)
            {
                currentColor = Color.red;
                while (yPos < destPos)
                {
                    clear();
                    yPos++;
                    draw();
                    try {threadElevator.sleep(DELAY);}
                    catch (InterruptedException e) {}
                }
            }

            // Declares that the thread is no longer active
            elevatorActive = false;
        }
    }
}

Share this post


Link to post

interesting, similar to C++ but some differences.
hmmm....are you using Java how to program by Deitel and Deitel? Cause I'm using C++ how to program by Deitel and Deitel, and that elevator simulation is very similar to the one in the C++ book.

btw, i'm going to be a Computer Science major when I enter college this fall. What are the programming classes like? Just syntax, syntax, syntax?

Share this post


Link to post

Too late now, but I want to get my meaningless ten cents into it.

Should I include his name in my assignment anyway, and boost his marks, or should I remain honest and submit it with only my name?


Depending on your relationship with that person. Usually if I'm taking a class with a good friend and it says that we are allowed to submit assignments in pairs, that friend and I decide that we will be submitting them in pairs, and we do. Occasionally only one of us really worked on a certain assignment, but we submit with both of our names all the time. The "divide and conquer" principle (well, not really). There's nothing dishonest about that.

Taking this to the extremes, there have been a few cases were I agreed to write a person's name just because he asked, but that is rare indeed, and only if the person is a good friend of mine. There have been cases in the past where I have been asked to do so and refused.

Another extreme case is a certain project in Introduction to Compilers which was 30% of the grade. I did it with two partners, but in the end I did it alone, and their business was mostly snoring next to me or listening to me explain my difficulties and then solving them. They both knew they were getting credit for no work done, the guy who graded the papers knew it. Meh, what do I care? The project was only 30% of the grade, the exam was the other 70%. I ended up with my 100 in that class, they got their 70s or 80s.

A1 (Inheretance and Polymorphism): 83%
A2 (Arrays): 73%
A3 (GUI and Data Structures): Unknown, probably around 15%.
A4 (File I/O, GUI, Data Structures): Unknown, probably around 80%.
A5 (Threads, Exceptions, GUI)


Interesting... Either your assignments are extremely difficult, or you don't regard them with full respect, or the testers are being bitches to you for no reason, but those marks are not what I'd generally consider good. In my Java class we had 6 assignments, and our grades were 5*100 + 97.

Oh yeah. Here's the dumb little program that I wrote:

Code....


Not ANOTHER elevator simulation! My friend (who was in fact my Java partner last year) took a Real-time class this semester, and his final project was also an elevator simulator (a graphical one, for that matter). I think he used Deitel&Deitel's Java code as a basis too. Lamers...

btw, i'm going to be a Computer Science major when I enter college this fall. What are the programming classes like? Just syntax, syntax, syntax?


Hardly. When you study the first language (normally C), you get a full syntax course and then study the concepts (variables, functions, arrays, pointers). Then you learn some simple algorithms. Often there is a class which teaches you how to implement algorithms using C or C++. With Assembler it's mostly the different command types, with C++ and Java you study the basic concepts of the language (Object-Oriented Design and all other crap like that). Syntax plays a role there, naturally, but it's a minor one. After all the syntax is never too difficult to grasp. Then you probably learn about some function libraries (like MFC or the Java graphical packages, communication packages, etc).

Share this post


Link to post
dr_st said:

Interesting... Either your assignments are extremely difficult, or you don't regard them with full respect, or the testers are being bitches to you for no reason, but those marks are not what I'd generally consider good. In my Java class we had 6 assignments, and our grades were 5*100 + 97.

People who were getting 90's and 100's in University programming classes are getting 60's and 70's in this program. Each assignment probably involves 20-40 hours of work on average. My marks are in the 85th percentile of the program. The average for our Java midterm was 53%. The 5th assignment was by far the easiest one.

There's also the fact that there are classes 31 hours a week. The next month will be 50 hour workweeks.

Share this post


Link to post

Java sucks. It's useless for learning programming and it's useless for productive programming.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×