Ask coding questions

← Back to all posts
Import code files to repl
PaulLeger (15)

Hi, I am professor and want to import source code files (C++'s examples) and later share with my students, Is it possible?

Answered by 21natzil (1205) [earned 5 cycles]
View Answer
Comments
hotnewtop
21natzil (1205)

You can upload files from your computer into a repl, and then have your students fork the repl, so each receives the same copy.

PaulLeger (15)

@21natzil Thanks ... I found the way!

HasanGonen (0)

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.undo.UndoManager;

public class UndoDemo extends JFrame {

private UndoManager undo = new UndoManager();
private JTextArea textArea = new JTextArea();

public UndoDemo() {

    super("Undo  Redo");
    LinkedList<String> cars = new LinkedList<String>();
    Container cp = getContentPane();
    cp.add(textArea = new JTextArea(10, 30), BorderLayout.CENTER);
    JPanel bp;
    cp.add(bp = new JPanel(), BorderLayout.SOUTH);

    undo = new UndoManager();
    textArea.getDocument().addUndoableEditListener(undo);
    
    JButton undoButton;
    bp.add(undoButton = new JButton("UNDO"));
   //cars.add(textArea);
    undoButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (undo.canUndo()) {
                undo.undo();
            } else {
                warn("Geri alinamaz");
            }
        }
    });

    JButton redoButton;
    bp.add(redoButton = new JButton("REDO"));
    redoButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (undo.canRedo()) {
                undo.redo();
            } else {
                warn("Ileri alinamaz");
            }
        }
    });
    pack();
    setDefaultCloseOperation(EXIT_ON_CLOSE);
}

void warn(String msg) {
    JOptionPane.showMessageDialog(this, "ERROR: " + msg, "ERROR",
            JOptionPane.WARNING_MESSAGE);
}




public static void main(String[] files) {
    
    /*
    cars.add("BMW");
    cars.add("Ford");
    cars.add("Mazda");
    System.out.println(cars);

*/

    new UndoDemo().setVisible(true);
}

}

[deleted]

leon332157 (341)

You can create a new repl and upload your code to it.

PaulLeger (15)

@leon332157 But, I have around 35 files because during a semester I teach many pieces of code. It is possible to upload a batch of sources code?

Mosrod (552)

@PaulLeger Yes, you can upload a folder of source code, and make your students fork that repl in the beginning of a semester, and they will have one repl for the whole semester with all of their files.
https://storage.googleapis.com/replit/images/1536091971976_59f3cf1c6250241787e583a4bee83cd2.gi

PaulLeger (15)

@Mosrod Yes, it is very useful!!!

Following this method, I have many files and want to compile/execute in an isolated way. Is it possible?

Mosrod (552)

@PaulLeger I don't think so, repl.it might add it in the future, but for now, you can rename the file that you want to run to 'main.py'.

Mitchelle_RR (3)

@Mosrod I don't see that option to add folders!! I don't know why.
https://storage.googleapis.com/replit/images/1548104544874_91bd494ad82f63192676500f921bb1ec.pn